Last active
July 27, 2017 06:20
-
-
Save selfup/89889327658d3b5aa33cfeb73e906aad to your computer and use it in GitHub Desktop.
This file contains hidden or 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, cache = {}) => (num < 2) | |
? num | |
: cache[num] || Object | |
.assign(cache, { [num]: (fib(num - 1, cache) + fib(num - 2, cache)) }) | |
[num]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment