Skip to content

Instantly share code, notes, and snippets.

@trys
Created April 8, 2015 15:59
Show Gist options
  • Save trys/0f6df0e9f8e9bff67238 to your computer and use it in GitHub Desktop.
Save trys/0f6df0e9f8e9bff67238 to your computer and use it in GitHub Desktop.
Problem Two
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