Created
October 12, 2016 00:55
-
-
Save gkucmierz/ba0c8cba14a28d910b914acdccf3c92a to your computer and use it in GitHub Desktop.
Fibonacci Number - Binet's Formula
This file contains hidden or 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
| // calculating Fibonacci Number using Binet's Formula | |
| fib = (n) => { | |
| let phi = (Math.sqrt(5) + 1) / 2; | |
| return Math.round((Math.pow(phi, n) - Math.pow(-phi, -n)) / Math.sqrt(5)); | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment