Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- unsigned int sum = 0;
- for(int i = 0; i < 1000; i++) //go through until 1000
- if(i % 3 == 0 || i % 5 == 0) //if it is divisble by 3 or 5
- sum += i; //add the number to sum.
- printf("Sum of natural numbers below 1000, that are divisible by 3 or 5 is %d", sum); //print the sum
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement