Skip to content

Commit d6f1ca1

Browse files
authored
Create ReachDestination.java
1 parent 4e379c8 commit d6f1ca1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import java.util.*;
2+
3+
class ReachDestination{
4+
5+
static void ReachDest(int source, int destination){
6+
7+
System.out.println("Source : " + source + "Destination : " + destination);
8+
9+
// base case
10+
11+
if(source == destination){
12+
System.out.println("REACHED");
13+
return;
14+
}
15+
16+
// processing - ek agge badhane k liye
17+
18+
source++;
19+
20+
// recursive call
21+
ReachDest(source, destination);
22+
23+
}
24+
25+
public static void main(String[] args){
26+
27+
Scanner scn = new Scanner(System.in);
28+
29+
int source = scn.nextInt();
30+
int destination = scn.nextInt();
31+
32+
ReachDest(source, destination);
33+
}
34+
}

0 commit comments

Comments
 (0)