From 506f390293f6497dbb3e38031a92e018de3403f8 Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Fri, 31 Mar 2023 23:06:23 -0700 Subject: init --- problem1/a.out | Bin 0 -> 13584 bytes problem1/problem1.c | 14 ++++++++++++++ 2 files changed, 14 insertions(+) create mode 100755 problem1/a.out create mode 100644 problem1/problem1.c (limited to 'problem1') diff --git a/problem1/a.out b/problem1/a.out new file mode 100755 index 0000000..8d5fd6e Binary files /dev/null and b/problem1/a.out 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 + +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); +} -- cgit v1.2.3-70-g09d2