Created
February 27, 2021 04:55
-
-
Save eengineergz/07d315d92b3458a8640cee31bce9c236 to your computer and use it in GitHub Desktop.
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
function fib(n, memo) { | |
memo = memo || {}; | |
if (memo[n]) return memo[n]; | |
if (n <= 2) return 1; | |
return (memo[n] = fib(n - 1, memo) + fib(n - 2, memo)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment