Last active
January 6, 2022 02:49
-
-
Save gaoryrt/fc202612043b8ef0ca92f8cfa30a607e to your computer and use it in GitHub Desktop.
nth fib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fib = num => num < 3 | |
? 1 | |
: fib(num - 1) + fib(num - 2) | |
console.log(fib(7)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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