We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Dear Community
I try to find all multipliers of 3 and 5 below 1000. This is the first objective of the Project Euler. (Project Euler)
But its not working... Even though it should! Here is my code:
int solution = 0;
int number = 1;
void setup() {
for (int i=0; i<350; i++) {
if ((number*3)<1000) {
int help = number*3;
//println(number*3);
solution =solution + help;
help = 0;
}
if ((number*5)<1000) {
int help2 = number*5;
//println(number*5);
solution = solution + help2;
help2 = 0;
}
number++;
}
println("Solution: "+solution);
}
If I printline the math, its giving out the correct numbers! But the solution 266333 seems not to be correct.
Thanks for your help! SirChregeli
Answers
you're adding numbers that are divisible by 15 twice.