We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e09c985 commit 6085b1fCopy full SHA for 6085b1f
src/main/java/com/thealgorithms/recursion/FibonacciSeries.java
@@ -18,4 +18,20 @@ public static int fibonacci(int n) {
18
return fibonacci(n - 1) + fibonacci(n - 2);
19
}
20
21
-}
+
22
23
+// n is the number upto which fibonacci sequence is required
24
+// for example n = 4 , output = 0 1 1 2
25
+ public static void fibo(int n){
26
+ int a = 0 ; int b = 1 ; int c =0;
27
+ System.out.print(a+" "+b);
28
+ for (int i = 2 ; i<n ; i++){
29
+ c = a+b;
30
+ System.out.print(" "+ c);
31
+ a = b ;
32
+ b = c ;
33
+ }
34
35
36
37
+}
0 commit comments