Created
June 5, 2011 14:55
-
-
Save nefarioustim/1009018 to your computer and use it in GitHub Desktop.
By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
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
for( | |
var sum = 0, f1 = 1, f2 = 2, next; | |
f2 < 4E6; | |
f2 & 1 || (sum += f2), next = f1 + f2, f2 = (f1 = f2, next) | |
); | |
console.log(sum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment