mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-08 18:32:56 +08:00
Correction of iteration limit of fibOptimized
This commit is contained in:
@ -88,7 +88,7 @@ public class Fibonacci {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
int prev = 0, res = 1, next;
|
int prev = 0, res = 1, next;
|
||||||
for (int i = 2; i < n; i++) {
|
for (int i = 2; i <= n; i++) {
|
||||||
next = prev + res;
|
next = prev + res;
|
||||||
prev = res;
|
prev = res;
|
||||||
res = next;
|
res = next;
|
||||||
|
Reference in New Issue
Block a user