Created
March 24, 2022 21:10
-
-
Save thomasgassmann/3a344eba15a3a07d090325b7bc23494b 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
| def fib(n): | |
| if n <= 2: | |
| return 1 | |
| a = [1, 1, 1] | |
| for i in range(3, n + 1): | |
| a[i % 3] = a[(i - 1) % 3] + a[(i - 2) % 3] | |
| return a[n % 3] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment