aboutsummaryrefslogtreecommitdiffstats
path: root/01-Multiples-of-3-and-5/euler1.c
diff options
context:
space:
mode:
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);
}