Skip to content

Instantly share code, notes, and snippets.

@sirkitree
Created April 15, 2012 19:53
Show Gist options
  • Select an option

  • Save sirkitree/2394511 to your computer and use it in GitHub Desktop.

Select an option

Save sirkitree/2394511 to your computer and use it in GitHub Desktop.
Project Euler challenge #2
// 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