Created
February 2, 2016 04:48
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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