Created
February 16, 2020 15:33
-
-
Save westscz/2864b5e4cee421d6318643ee8e88fde3 to your computer and use it in GitHub Desktop.
fibonacci
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(128) | |
def fibonaci(n): | |
if n > 2: | |
return fibonaci(n-1) + fibonaci(n-2) | |
if 0 < n <= 2: | |
return 1 | |
if n == 0: | |
return 0 | |
else: | |
raise ValueError |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment