Created
March 30, 2017 17:35
-
-
Save Cornpop456/71e1a1309e821b6a90b5247a13439f09 to your computer and use it in GitHub Desktop.
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): | |
if n == 0: | |
return 0 | |
elif n == 1: | |
return 1 | |
else: | |
return fib(n - 1) + fib(n - 2) | |
def wrapper(func): | |
cache = {} | |
def inner(n): | |
if n not in cache: | |
cache[n] = func(n) | |
return cache[n] | |
return inner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment