Skip to content

Instantly share code, notes, and snippets.

@basnijholt
Created November 1, 2017 10:40
Show Gist options
  • Save basnijholt/919610eb405b21c9579c49699a0efe84 to your computer and use it in GitHub Desktop.
Save basnijholt/919610eb405b21c9579c49699a0efe84 to your computer and use it in GitHub Desktop.
Fibonacci with memoizing
from functools import lru_cache
@lru_cache()
def fib(n):
if n in [0, 1]:
return 1
else:
return fib(n-1) + fib(n-2)
fib(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment