extras: add P16-P23, P25
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
This commit is contained in:
14
P20.java
Normal file
14
P20.java
Normal file
@@ -0,0 +1,14 @@
|
||||
public class P20 {
|
||||
public static void main(String[] args) {
|
||||
int n = 10;
|
||||
System.out.print("Fibonacci Series of length " + n + ": ");
|
||||
fibonacci(0, 1, n);
|
||||
}
|
||||
|
||||
public static void fibonacci(int a, int b, int n) {
|
||||
if (n == 0)
|
||||
return;
|
||||
System.out.print(a + " ");
|
||||
fibonacci(b, a + b, n - 1);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user