Skip to content

Instantly share code, notes, and snippets.

@selfup
Last active July 27, 2017 06:20
Show Gist options
  • Save selfup/89889327658d3b5aa33cfeb73e906aad to your computer and use it in GitHub Desktop.
Save selfup/89889327658d3b5aa33cfeb73e906aad to your computer and use it in GitHub Desktop.
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