Created
July 15, 2018 09:37
-
-
Save solen003/7b99b8a18a51ff48468b2de7072ca0f9 to your computer and use it in GitHub Desktop.
use of lru_cache
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
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