Last active
February 20, 2019 12:35
-
-
Save alenaksu/648e81f3c539b9360be119f0617662fb to your computer and use it in GitHub Desktop.
Fibonacci number generator using the Binet's formula
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fibonacci(n) { | |
const delta = Math.sqrt(5); | |
return ( | |
(Math.pow(1 + delta, n) - Math.pow(1 - delta, n)) / (Math.pow(2, n) * delta) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment