Skip to content

Instantly share code, notes, and snippets.

@wintercn
Created January 3, 2025 00:58
Show Gist options
  • Save wintercn/2103c62050327c2a62447681ae116a46 to your computer and use it in GitHub Desktop.
Save wintercn/2103c62050327c2a62447681ae116a46 to your computer and use it in GitHub Desktop.
fibnacci.js
const fib = n => n === 0 ? [0, 1] :
n % 2 ? (([a, b]) => [b, a + b])(fib(n - 1)) :
(([a, b]) => [a * b + a * (b - a), a * a + b * b])(fib(n / 2));
Array(10).fill(0).map((v, n) => fib(n)[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment