Skip to content

Instantly share code, notes, and snippets.

@rgardner
Created November 25, 2014 06:28
Show Gist options
  • Save rgardner/df385792c49db51014e2 to your computer and use it in GitHub Desktop.
Save rgardner/df385792c49db51014e2 to your computer and use it in GitHub Desktop.
def fibonacci(n, cache={}):
if n in cache:
return cache[n]
cache[n] = fibonacci[n-1] + fibonacci[n-2]
return cache[n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment