Skip to content

Instantly share code, notes, and snippets.

@KimSarabia
Last active October 11, 2017 21:13
Show Gist options
  • Save KimSarabia/aacdbb41deb8988483325f91c59ede9f to your computer and use it in GitHub Desktop.
Save KimSarabia/aacdbb41deb8988483325f91c59ede9f to your computer and use it in GitHub Desktop.
Constant Fibonacci
// 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