The Sum of the Multiples of 3 or 5 to 1000
THE SUM IS:
To find the sum of the multiples, the code evaluates every number from 0 to 1000.
It checks to see if the value for x can be evenly divided by 3 or 5. If it does, it is added to
the variable sum. The loop continues until 1000 is reached and it displays the final sum.
The following code was used to find the sum of the multiples of 3 and 5
var sum = 0;
for(var x = 0; x < 1000; x++)
{
if(x % 3 === 0 || x % 5 === 0)
{
sum = sum + x;
}
}
HOME
MULTIPPLES OF THREE OR FIVE