Skip to content

Instantly share code, notes, and snippets.

@MartinSvarrer
Created November 18, 2014 10:10
Show Gist options
  • Save MartinSvarrer/3794f8c54f59a2c88eaf to your computer and use it in GitHub Desktop.
Save MartinSvarrer/3794f8c54f59a2c88eaf to your computer and use it in GitHub Desktop.
function fib (n) {
var sqrt5 = Math.sqrt(5)
return Math.round(1/sqrt5 *(Math.pow((1+sqrt5)/2, n) - Math.pow((1-sqrt5)/2, n)));
}
// output large fib number
console.log(fib2(1000));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment