Skip to content

Instantly share code, notes, and snippets.

@alenaksu
Last active February 20, 2019 12:35
Show Gist options
  • Save alenaksu/648e81f3c539b9360be119f0617662fb to your computer and use it in GitHub Desktop.
Save alenaksu/648e81f3c539b9360be119f0617662fb to your computer and use it in GitHub Desktop.
Fibonacci number generator using the Binet's formula
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