Skip to content

Commit fe9bc42

Browse files
committed
recursion simple
1 parent 53b9a31 commit fe9bc42

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/binod/RecursionDemo1.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package binod;
2+
public class RecursionDemo1 {
3+
//print numbers from 5 to 1
4+
public static void main(String[] args) {
5+
printNumber(5);
6+
7+
}
8+
//Q.Why do we make static method
9+
public static void printNumber(int n){
10+
//base condition
11+
if(n==0){
12+
return;
13+
}
14+
System.out.println(n);
15+
printNumber(n-1);
16+
}
17+
}

0 commit comments

Comments
 (0)