Skip to content

Commit d417c84

Browse files
mahbubcsejumahbubur.rahman
authored and
mahbubur.rahman
committed
Updated the matrix exponentiation approach of finding nth fibonacci.
- Removed some extra spaces - Added the complexity of bruteforce algorithm - Removed unused function called zerro() - Added some docktest based on request
1 parent b159705 commit d417c84

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

matrix/nth_fibonacci_using_matrix_exponentiation.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
-> [f(n),f(n-1)] = [[1,1],[1,0]]^(n-1) * [f(1),f(0)]
1313
So we just need the n times multiplication of the matrix [1,1],[1,0]].
1414
We can decrease the n times multiplication by following the divide and conquer approach.
15-
1615
"""
1716
from __future__ import print_function
1817

@@ -38,7 +37,7 @@ def identity(n):
3837
def nth_fibonacci(n):
3938
"""
4039
>>> nth_fibonacci(100)
41-
354224848179261915075L
40+
354224848179261915075
4241
>>> nth_fibonacci(-100)
4342
-100
4443
"""

0 commit comments

Comments
 (0)