Created
April 15, 2012 19:53
-
-
Save sirkitree/2394511 to your computer and use it in GitHub Desktop.
Project Euler challenge #2
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
| // Project Euler challenge #2 | |
| // https://projecteuler.net/problem=2 | |
| var a = 1, b = 2, sum = 0; | |
| while (a < 4000000) { | |
| if (a % 2 == 0) sum += a; | |
| var tmp = a; | |
| a = b; | |
| b += tmp; | |
| } | |
| console.log(sum); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment