15
P4.java
Normal file
15
P4.java
Normal file
@@ -0,0 +1,15 @@
|
||||
class P4 {
|
||||
public static void main(String[] _args) {
|
||||
int n = 10;
|
||||
int a = 0, b = 1;
|
||||
System.out.println("First " + n + " elements of the fibonacci series:");
|
||||
new P4().fibo(n, a, b);
|
||||
}
|
||||
|
||||
void fibo(int n, int a, int b) {
|
||||
if (n == 0)
|
||||
return;
|
||||
System.out.println(a);
|
||||
fibo(n - 1, b, a + b);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user