Skip to content

Commit b706572

Browse files
committed
Done with the required changes
1 parent b7db4ca commit b706572

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

maths/fibonacci.py

+2
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ def matrix_pow_np(m: ndarray, power: int) -> ndarray:
269269
"""
270270
result = np.array([[1, 0], [0, 1]], dtype=int) # Identity Matrix
271271
base = m
272+
if(power < 0): # Negative power is not allowed
273+
raise ValueError("power is negative")
272274
while power:
273275
if power % 2 == 1:
274276
result = np.dot(result, base)

0 commit comments

Comments
 (0)