Last active
February 19, 2023 15:33
-
-
Save poacosta/2b653caf620f5de1733eba70def9d104 to your computer and use it in GitHub Desktop.
n-th fibonacci with n up to 2_000_000
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 numpy import matrix | |
def fib(n): | |
return (matrix( | |
'0 1; 1 1' if n >= 0 else '-1 1; 1 0', object | |
) ** abs(n))[0, 1] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment