Skip to content

Instantly share code, notes, and snippets.

@atushi
Created July 12, 2013 09:46

Revisions

  1. atushi created this gist Jul 12, 2013.
    14 changes: 14 additions & 0 deletions projecteuler2.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    var TARGETNUM = 4000000;
    var i = 0;
    var b = 0;
    var a = 1;
    var answer = 0;
    while (true) {
    if (b%2==0) answer = answer + b;
    tmp = b;
    b = a;
    if (TARGETNUM < b) break;
    a = tmp + a;
    i++;
    }
    console.log(answer);