From 699ba680f044f6e1dfb71d656bf984c1559622a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Wed, 30 Dec 2015 14:24:52 +0100 Subject: [PATCH] Added brute solution Unfortuantlly it's bit too slow --- Project-Euler/001/bruteforce.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Project-Euler/001/bruteforce.c diff --git a/Project-Euler/001/bruteforce.c b/Project-Euler/001/bruteforce.c new file mode 100644 index 0000000..9639df4 --- /dev/null +++ b/Project-Euler/001/bruteforce.c @@ -0,0 +1,32 @@ +#include +#include +#include +#include + +// Use: +// bruteforce +// n numbers to calculate (PE 1) +// number #1 to calculate (PE 1000) +// number #2 to calculate +// ... +// number n to calculate + +int main() { + int n; + scanf("%d",&n); + long arr[n]; + for(int i = 0; i < n; i++){ + scanf("%li",&arr[i]); + } + + for (int i = 0; i < n; i++) + { + long sum = 0; + for (long j = 1; j < arr[i]; j++) + { + if (j % 3 == 0 || j % 5 == 0) + sum += j; + } + printf("%li\n", sum); + } +}