Skip to content

Instantly share code, notes, and snippets.

@alenaksu
Last active November 8, 2024 11:24
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
const fibonacci = (n: number): number => {
const delta = Math.sqrt(5);
return Math.floor(((1 + delta) ** n - (1 - delta) ** n) / (2 ** n * delta));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment