Created
January 11, 2016 22:13
-
-
Save jalehman/217e8309be1eff2a219d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// 1. Compute the sum of squares up to `n`, where n is 10. | |
var n = 10; | |
var i = 0; | |
var result = 0; | |
while (i < n) { | |
result = result + (i * i); | |
i++; | |
} | |
console.log(result); | |
// 2. How about the sum of cubes of even numbers up to 10? | |
n = 10; | |
i = 0; | |
result = 0; | |
while (i < n) { | |
result = result + (i * i * i); | |
i = i + 2; | |
} | |
console.log(result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment