Skip to content

Arth longest subarray #6458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
new method without recursion
  • Loading branch information
ArthBachhuka123 committed Aug 2, 2025
commit 6085b1f54647ae5f16d3d86caa4c78965852a876
18 changes: 17 additions & 1 deletion src/main/java/com/thealgorithms/recursion/FibonacciSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,20 @@ public static int fibonacci(int n) {
return fibonacci(n - 1) + fibonacci(n - 2);
}
}
}


// n is the number upto which fibonacci sequence is required
// for example n = 4 , output = 0 1 1 2
public static void fibo(int n){
int a = 0 ; int b = 1 ; int c =0;
System.out.print(a+" "+b);
for (int i = 2 ; i<n ; i++){
c = a+b;
System.out.print(" "+ c);
a = b ;
b = c ;
}

}

}