Created
April 14, 2015 00:00
-
-
Save mr1337357/57c35cc97fba444a669b to your computer and use it in GitHub Desktop.
recursive fib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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