diff options
Diffstat (limited to 'problem1/problem1.c')
-rw-r--r-- | problem1/problem1.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/problem1/problem1.c b/problem1/problem1.c new file mode 100644 index 0000000..a2aad3d --- /dev/null +++ b/problem1/problem1.c @@ -0,0 +1,14 @@ +/* + If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. */ + +#include <stdio.h> + +int main() { + unsigned int sum; + for (int i = 1; i < 1000; i++) { + if (i % 3 == 0 || i % 5 == 0) { + sum += i; + } + } + printf("%u\n", sum); +} |