Skip to content

Instantly share code, notes, and snippets.

@wildskyf
Last active May 8, 2019 14:27
Show Gist options
  • Save wildskyf/d3be81f73fea07d5f6ddb207a9365da3 to your computer and use it in GitHub Desktop.
Save wildskyf/d3be81f73fea07d5f6ddb207a9365da3 to your computer and use it in GitHub Desktop.
var map = {}
function fibonacci(n) {
if (n <= 1) return n
map[n-2] = map[n-2] || fibonacci(n-2)
map[n-1] = map[n-1] || fibonacci(n-1)
return map[n-2] + map[n-1]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment