Skip to content

Instantly share code, notes, and snippets.

@NEbere
Created February 2, 2016 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NEbere/880e3fadf4e051f0863a to your computer and use it in GitHub Desktop.
Save NEbere/880e3fadf4e051f0863a to your computer and use it in GitHub Desktop.
Calculates the sum of 1 to 1000, if the number is a multiple of 5 or three,double it and add it to the sum.
$(document).ready(function(){
var sum1= 0, res = 0, totalSum = 0;
for (var x = 1; x <= 1000; x++)
{
if (x % 3 === 0 || x % 5 === 0)
{
k = x * 2;
sum1 += k;
}
res += x;
}
totalSum = res + sum1;
alert(totalSum);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment