Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save carmandomx/e3a68ecebec53dcbb2308b26c4af57e2 to your computer and use it in GitHub Desktop.
Save carmandomx/e3a68ecebec53dcbb2308b26c4af57e2 to your computer and use it in GitHub Desktop.
fib.js
const fib = (pos, memos) => {
if (pos === 0) {
return 0
}
if (pos === 1) {
return 1
}
if (memos[pos] !== undefined) {
return memos[pos]
}
memos[pos] = fib(pos - 1, memos) + fib(pos - 2, memos)
return memos[pos]
}
console.log(fib(1000, {}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment