Last active
March 30, 2020 19:57
-
-
Save luizomf/2a44f26d91f25a755420cb2d3bf085e1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| def fibonacci_sequence(n: int) -> int: | |
| """Sequência Fibonacci with memoization""" | |
| if n < 1: | |
| return 0 | |
| if n <= 2: | |
| return 1 | |
| return fibonacci_sequence(n - 1) + fibonacci_sequence(n - 2) | |
| if __name__ == "__main__": | |
| for i in range(1000): | |
| print(fibonacci_sequence(i)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment