summaryrefslogtreecommitdiff
path: root/problem1
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2023-03-31 23:06:23 -0700
committerKai Stevenson <kai@kaistevenson.com>2023-03-31 23:06:23 -0700
commit506f390293f6497dbb3e38031a92e018de3403f8 (patch)
treed7f6192354415d1b2e6c04e232ef407294e0fa17 /problem1
Diffstat (limited to 'problem1')
-rwxr-xr-xproblem1/a.outbin0 -> 13584 bytes
-rw-r--r--problem1/problem1.c14
2 files changed, 14 insertions, 0 deletions
diff --git a/problem1/a.out b/problem1/a.out
new file mode 100755
index 0000000..8d5fd6e
--- /dev/null
+++ b/problem1/a.out
Binary files differ
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);
+}