Skip to content

Instantly share code, notes, and snippets.

@mstade
Last active August 29, 2015 13:57
Show Gist options
  • Save mstade/9483764 to your computer and use it in GitHub Desktop.
Save mstade/9483764 to your computer and use it in GitHub Desktop.
Fibonacci
// 0 and below will yield 0, everything else follows the sequence.
function fib(n) {
const sq = Math.sqrt(5)
, gr = (1 + sq) / 2
return Math.floor(Math.pow(gr, n) / sq + 0.5)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment