MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / main

Function main

matrix/nth_fibonacci_using_matrix_exponentiation.py:73–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71
72
73def main() -> None:
74 for ordinal in "0th 1st 2nd 3rd 10th 100th 1000th".split():
75 n = int("".join(c for c in ordinal if c in "0123456789")) # 1000th --> 1000
76 print(
77 f"{ordinal} fibonacci number using matrix exponentiation is "
78 f"{nth_fibonacci_matrix(n)} and using bruteforce is "
79 f"{nth_fibonacci_bruteforce(n)}\n"
80 )
81 # from timeit import timeit
82 # print(timeit("nth_fibonacci_matrix(1000000)",
83 # "from main import nth_fibonacci_matrix", number=5))
84 # print(timeit("nth_fibonacci_bruteforce(1000000)",
85 # "from main import nth_fibonacci_bruteforce", number=5))
86 # 2.3342058970001744
87 # 57.256506615000035
88
89
90if __name__ == "__main__":

Calls 3

nth_fibonacci_matrixFunction · 0.85
nth_fibonacci_bruteforceFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected