-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNto1.java
More file actions
41 lines (38 loc) · 776 Bytes
/
Nto1.java
File metadata and controls
41 lines (38 loc) · 776 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
37
38
39
40
41
package com.Recursion;
public class Nto1 {
public static void main(String[] args) {
funBoth(5);
}
// concept
static void concept(int n) {
if (n == 0) {
return;
}
System.out.println(n);
// concept(n--);
concept(--n);
// n-- vs --n
}
static void fun(int n) {
if (n == 0) {
return;
}
System.out.println(n);
fun(n-1);
}
static void funRev(int n) {
if (n == 0) {
return;
}
funRev(n-1);
System.out.println(n);
}
static void funBoth(int n) {
if (n == 0) {
return;
}
System.out.println(n);
funBoth(n-1);
System.out.println(n);
}
}