-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRecursiontext02.java
More file actions
32 lines (24 loc) · 596 Bytes
/
Recursiontext02.java
File metadata and controls
32 lines (24 loc) · 596 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
public class Recursiontext02 {
public static void main(String[] args) {
/*
int n = 4;
int retVlue = sum(n);
System.out.println(retVlue);
*/
int n = 5;
int retVlue = method(n);
System.out.println(retVlue);//120
}
public static int sum(int n){
if(n == 1){
return 1;
}
return + sum(n-1);
}
public static int method(int n){
if(n == 1){
return 1;
}
return n * method(n-1);
}
}