for (i = 0; i <= 1000; i++) { if ( i % 3 === 0){ console.log(i); } if ( i % 5 === 0){ console.log(i); } }
I wan
If you want to avoid counting multiple of 15 twice in your sum :
int sum = 0; for (i = 0; i <= 1000; i++) { if ( i % 3 === 0 || i % 5 === 0){ sum += i; // or sum = sum + i } }