Created
June 20, 2020 16:57
-
-
Save Allwin12/d3a74e14243a4da858b405122b298a8a to your computer and use it in GitHub Desktop.
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) | |
def fibonacci(n): | |
if n == 1: | |
return 1 | |
if n == 2: | |
return 1 | |
elif n > 2: | |
return fibonacci(n - 1) + fibonacci(n - 2) | |
for i in range(1, 1001): | |
print(i, ':', fibonacci(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment