Skip to content

Commit 3113fdd

Browse files
authored
Update fibonacci-number.cpp
1 parent 0fcdecc commit 3113fdd

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

C++/fibonacci-number.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@
44
class Solution {
55
public:
66
int fib(int N) {
7-
if (N == 0) {
8-
return 0;
9-
}
10-
117
vector<vector<int>> T = {{1, 1},
128
{1, 0}};
13-
return matrixExpo(T, N - 1)[0][0];
9+
return matrixExpo(T, N)[1][0];
1410
}
1511

1612
private:

0 commit comments

Comments
 (0)