Skip to content

Instantly share code, notes, and snippets.

@solen003
Created July 15, 2018 09:37
Show Gist options
  • Save solen003/7b99b8a18a51ff48468b2de7072ca0f9 to your computer and use it in GitHub Desktop.
Save solen003/7b99b8a18a51ff48468b2de7072ca0f9 to your computer and use it in GitHub Desktop.
use of lru_cache
from functools import lru_cache
@lru_cache(maxsize = 1000)
# default is 128 values
def fibonacci3(n):
if n == 1 or n == 2:
return 1
elif n > 2:
return fibonacci3(n-1) + fibonacci3(n-2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment