forked from joharbatta/DataStructure-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathr2.java
More file actions
27 lines (25 loc) · 435 Bytes
/
r2.java
File metadata and controls
27 lines (25 loc) · 435 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
class rec1
{
public rec(int i)
{
int result=0;
if(i==5) { //base case
return 5;
}
else { //recursive case
result = rec(i + 1);
System.out.println(result);
return i;
}
}
}
class r2
{
public static void main(String args[])
{
int x;
rec1 r=new rec1();
x=r.rec(1);
System.out.println(x);
}
}