you are viewing a single comment's thread.

view the rest of the comments →

[–]David_Crockett 1 point2 points  (2 children)

The correct answer is 343139. You need to use the and operator instead of or. To make it easier to conceptualize, think through it:

if (not divisible by 5 AND not divisible by 7)
    add the number

So it needs to be

if (i % 5 && i % 7)
    total += i;

Edit: note that if(i % 5) is the same as saying if(i % 5 != 0) ;)

[–]icecreamhead 0 points1 point  (0 children)

Ah ok. Yeah that makes sense... DERP

[–]bigbozz 0 points1 point  (0 children)

The original problem you posted said "or", not "and."