Skip to content

Instantly share code, notes, and snippets.

@trys
Created April 8, 2015 16:12
Show Gist options
  • Save trys/2feed3e454ec9655a161 to your computer and use it in GitHub Desktop.
Save trys/2feed3e454ec9655a161 to your computer and use it in GitHub Desktop.
Problem Six
var sums = 0,
smallest = 1,
largest = 100,
sumOfSquares = 0,
squareOfSums = 0;
for ( i = smallest; i <= largest; i++ ) {
sumOfSquares += i * i;
}
for ( var i = smallest; i <= largest; i++ ) {
sums += i;
}
squareOfSums = sums * sums;
document.write( squareOfSums - sumOfSquares );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment