Skip to content

Instantly share code, notes, and snippets.

@web20opensource
Created April 10, 2015 20:56
Show Gist options
  • Save web20opensource/a76d6a60cdac3e102b79 to your computer and use it in GitHub Desktop.
Save web20opensource/a76d6a60cdac3e102b79 to your computer and use it in GitHub Desktop.
var fib = [1,2] , i=0;j=1 , index=2 , sum=2;
while ( fib[j]<4*Math.pow(10,6) ){
fib[index] = fib[i]+fib[j];
if (4*Math.pow(10,6)<=fib[index]) {
break;
}
if ( !(fib[index]%2) )
sum+=fib[index];
index++;
i++;
j++;
}
console.log(sum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment