-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreursion1.java
More file actions
37 lines (34 loc) · 889 Bytes
/
reursion1.java
File metadata and controls
37 lines (34 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import javax.print.attribute.standard.PrinterName;
// public class reursion1{
// public static int calfactorial(int n){
// if(n==0 || n==1){
// return 1;
// }
// int fac_nm1 = calfactorial(n-1);
// int fac_nm2 = n * fac_nm1;
// return fac_nm2;
// }
// public static void main(String args[]){
// int n = 5;
// int ans = calfactorial(n);
// System.out.println(ans);
// }
// }
public class reursion1{
public static void printfib(int a , int b , int n){
if(n == 0){
return;
}
int c = a + b;
System.out.println(c);
printfib(b, c, n-1);
}
public static void main(String args[]){
int a = 0 ;
int b = 1;
int n = 7;
System.out.println(a);
System.out.println(b);
printfib(a, b, n-2);
}
}