2011-04-11 11:38:22 +02:00
|
|
|
sum = 2;
|
|
|
|
fib = new Array( 1, 2, 3 );
|
|
|
|
while(fib[2] < 4000000)
|
|
|
|
{
|
|
|
|
fib[2] = fib[0] + fib[1];
|
|
|
|
if(fib[2] % 2 == 0)
|
|
|
|
sum += fib[2];
|
2012-04-11 14:49:45 +02:00
|
|
|
fib[0] = fib[1];
|
2011-04-11 11:38:22 +02:00
|
|
|
fib[1] = fib[2];
|
|
|
|
}
|
|
|
|
console.log(sum );
|