Skip to content

Commit

Permalink
101-natural.c
Browse files Browse the repository at this point in the history
  • Loading branch information
victorpreston committed Jun 20, 2023
1 parent d19c146 commit ad6350d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Binary file added 0x02-functions_nested_loops/101-natural
Binary file not shown.
30 changes: 30 additions & 0 deletions 0x02-functions_nested_loops/101-natural.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <stdio.h>

/**
* main - computes and prints the sum of all the multiples
* of 3 or 5 below 1024
* Return: Always 0 (success)
*/
int main(void)
{
unsigned long int sum3, sum5, sum;
int i;

sum3 = 0;
sum5 = 0;
sum = 0;

for (i = 0; i < 1024; ++i)
{
if ((i % 3) == 0)
{
sum3 = sum3 + i;
} else if ((i % 5) == 0)
{
sum5 = sum5 + i;
}
}
sum = sum3 + sum5;
printf("%lu\n", sum);
return (0);
}

0 comments on commit ad6350d

Please sign in to comment.