Skip to content

Instantly share code, notes, and snippets.

@xcarpentier
Created January 19, 2020 19:30
Show Gist options
  • Save xcarpentier/ed0e3def58a391619a113ad152f8d6b4 to your computer and use it in GitHub Desktop.
Save xcarpentier/ed0e3def58a391619a113ad152f8d6b4 to your computer and use it in GitHub Desktop.
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