File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed
src/main/java/com/thealgorithms/recursion Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change 77 FIBONACCI 0 1 1 2 3 5 8 13 21 34 55 ...
88*/
99
10- /*T his is optimized solution for fibonacci series. It computes fibonacci series in linear(O(n)) time complexity */
11-
10+ /* This is optimized solution for fibonacci series. It computes fibonacci series in linear (O(n)) time complexity */
1211public final class FibonacciOptimized {
13- static int fibonacci (int limit , int num1 , int num2 ){
14- if (limit ==1 ){
12+
13+ private FibonacciOptimized () {
14+ // Prevent instantiation
15+ }
16+
17+ static int fibonacci (int limit , int num1 , int num2 ) {
18+ if (limit == 1 ) {
1519 return num1 ;
16- }
17- else {
18- return fibonacci (limit -1 , num2 , num1 +num2 );
20+ } else {
21+ return fibonacci (limit - 1 , num2 , num1 + num2 );
1922 }
2023 }
21-
22- }
23-
24+ }
You can’t perform that action at this time.
0 commit comments