Skip to content

Instantly share code, notes, and snippets.

@sheniff
Created May 3, 2015 03:55
Show Gist options
  • Select an option

  • Save sheniff/9a961889268ff78ff603 to your computer and use it in GitHub Desktop.

Select an option

Save sheniff/9a961889268ff78ff603 to your computer and use it in GitHub Desktop.
Spoiler Alert: Project Euler 2
var sum = 2,
prev = 1,
prev2 = 2,
curr;
while ((curr = prev + prev2) < 4000000) {
prev = prev2;
prev2 = curr;
!(curr % 2) && (sum += curr);
}
console.log(sum);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment