Skip to content

Instantly share code, notes, and snippets.

@Cornpop456
Created March 30, 2017 17:35
Show Gist options
  • Save Cornpop456/71e1a1309e821b6a90b5247a13439f09 to your computer and use it in GitHub Desktop.
Save Cornpop456/71e1a1309e821b6a90b5247a13439f09 to your computer and use it in GitHub Desktop.
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