aboutsummaryrefslogtreecommitdiffstats
path: root/01-Multiples-of-3-and-5/euler1.c
diff options
context:
space:
mode:
authormjfernez <mjfernez@gmail.com>2021-10-12 20:18:28 -0400
committermjfernez <mjfernez@gmail.com>2021-10-12 20:18:28 -0400
commit3cf128d6da667d00bb5bb659413ea55a98a02aff (patch)
tree12eb90997dfa63d65fe6da714626271272342320 /01-Multiples-of-3-and-5/euler1.c
parent009ce017d99a8deb2089438381c273e8f3ea3b67 (diff)
downloadProject_Euler_Solutions-master.tar.gz
Added description. x86 solutions for some problemsHEADmaster
Diffstat (limited to '01-Multiples-of-3-and-5/euler1.c')
-rw-r--r--01-Multiples-of-3-and-5/euler1.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/01-Multiples-of-3-and-5/euler1.c b/01-Multiples-of-3-and-5/euler1.c
index d89956e..ff24a08 100644
--- a/01-Multiples-of-3-and-5/euler1.c
+++ b/01-Multiples-of-3-and-5/euler1.c
@@ -3,11 +3,11 @@
//Problem 1: multiples of 3 and 5
int main(){
int max = 1000;
- int i; double sum;
+ int i, sum = 0;
- for (i=0;i<max; i++)
- if(i%3 == 0 || i%5==0)
- sum+= (double) i;
+ for (i; i<max; i++)
+ if (!(i%3) || !(i%5))
+ sum+=i;
- printf("%f\n", sum);
+ printf("%d\n", sum);
}