Skip to content

Instantly share code, notes, and snippets.

@mr1337357
Created April 14, 2015 00:00
Show Gist options
  • Save mr1337357/57c35cc97fba444a669b to your computer and use it in GitHub Desktop.
Save mr1337357/57c35cc97fba444a669b to your computer and use it in GitHub Desktop.
recursive fib
def fib(n,cache={0:1,1:1}):
try:
return cache[n]
except:
cache[n]=fib(n-1)+fib(n-2)
return cache[n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment