Created
January 19, 2020 19:30
-
-
Save xcarpentier/ed0e3def58a391619a113ad152f8d6b4 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 nfib_data = {} | |
function fibo(n: number) { | |
if(nfib_data[n]) { | |
return nfib_data[n] | |
} | |
let result | |
if(n === 0 || n === 1) { | |
result = n; | |
} else { | |
result = fibo(n - 1) + fibo(n - 2) | |
} | |
nfib_data[n] = result; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment