(a: Matrix, b: int)
| 29 | |
| 30 | |
| 31 | def modular_exponentiation(a: Matrix, b: int) -> Matrix: |
| 32 | matrix = Matrix([[1, 0], [0, 1]]) |
| 33 | while b > 0: |
| 34 | if b & 1: |
| 35 | matrix *= a |
| 36 | a *= a |
| 37 | b >>= 1 |
| 38 | return matrix |
| 39 | |
| 40 | |
| 41 | def fibonacci_with_matrix_exponentiation(n: int, f1: int, f2: int) -> int: |
no test coverage detected