# Problem 1: Multiples of 3 and 5 problem

Tell us what’s happening:
For some reason this code is not working, and I don’t even know why

``````
function multiplesOf3and5(number) {
var i;
for (i=3; i++; i<number) {
var sum=0;
if (i%5 ===0 || i%3 ===0) sum=sum+i;

}
return sum;
}

multiplesOf3and5(1000);
``````

You are setting `sum` to 0 at every iteration of the loop

Your problem has been solved, but note that this is very inefficient way of solving it.
A much more efficient way of solving it is to sum all multiples of 3, all multiples of 5 and then subtract all multiples of 15.

So you want to calculate sum(n=1…floor(1000/3),3xn) + sum(n=1…floor(1000/5),5xn)-sum(n=1…floor(1000/15)) This ends up as three arithmetic sums
3x333x(333+1)/2+5x199x(199+1)/2- 15x66x(66+1)/2

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

Note: Backticks are not single quotes. 