Skip to content

Instantly share code, notes, and snippets.

@gaoryrt
Last active January 6, 2022 02:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaoryrt/fc202612043b8ef0ca92f8cfa30a607e to your computer and use it in GitHub Desktop.
Save gaoryrt/fc202612043b8ef0ca92f8cfa30a607e to your computer and use it in GitHub Desktop.
nth fib
const fib = num => num < 3
? 1
: fib(num - 1) + fib(num - 2)
console.log(fib(7))
const Y = f => (x => f(x(x)))(x => f((...y) => x(x)(...y)))
const fib = Y(
f => num => num < 3
? 1
: f(num - 1) + f(num - 2)
)
console.log(fib(7))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment