Created
April 8, 2015 15:59
-
-
Save trys/0f6df0e9f8e9bff67238 to your computer and use it in GitHub Desktop.
Problem Two
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
var result = 0, | |
holding = 0; | |
previous = 1, | |
fibonacci = 1; | |
while ( fibonacci <= 4000000 ) { | |
holding = fibonacci; | |
fibonacci += previous; | |
if ( fibonacci % 2 === 0 ) | |
result += fibonacci; | |
previous = holding; | |
} | |
document.write( result ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment