Skip to content

Instantly share code, notes, and snippets.

@gkucmierz
Created October 12, 2016 00:55
Show Gist options
  • Select an option

  • Save gkucmierz/ba0c8cba14a28d910b914acdccf3c92a to your computer and use it in GitHub Desktop.

Select an option

Save gkucmierz/ba0c8cba14a28d910b914acdccf3c92a to your computer and use it in GitHub Desktop.
Fibonacci Number - Binet's Formula
// 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