Skip to content

Commit b0f81f1

Browse files
committed
Correction of iteration limit of fibOptimized
1 parent 86d6a59 commit b0f81f1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

DynamicProgramming/Fibonacci.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ private static int fibOptimized(int n) {
8888
return 0;
8989
}
9090
int prev = 0, res = 1, next;
91-
for (int i = 2; i < n; i++) {
91+
for (int i = 2; i <= n; i++) {
9292
next = prev + res;
9393
prev = res;
9494
res = next;

0 commit comments

Comments
 (0)