Last active
October 11, 2017 21:13
-
-
Save KimSarabia/aacdbb41deb8988483325f91c59ede9f to your computer and use it in GitHub Desktop.
Constant Fibonacci
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
// https://www.mathsisfun.com/numbers/golden-ratio.html | |
// Use Golden Ratio to Find Fibonacci given n is term number | |
function fibonacci(n) { | |
return Math.round( | |
(Math.pow((1 + Math.sqrt(5)) / 2, n) — | |
Math.pow(-2 / (1 + Math.sqrt(5)), n)) / | |
Math.sqrt(5) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment