Skip to content

Commit 0c2e8ea

Browse files
committed
solve: P07_03_팩토리얼
1 parent 8eb1d16 commit 0c2e8ea

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package inflearn.problemsolving.p07_recursive_tree_graph;
2+
3+
import java.util.Scanner;
4+
5+
public class P07_03_팩토리얼 {
6+
7+
public static int solve(int n) {
8+
if (n == 1) return 1;
9+
return n * solve(n-1);
10+
}
11+
12+
public static void main(String[] args) {
13+
// 5 => 120
14+
Scanner in = new Scanner(System.in);
15+
int input = in.nextInt();
16+
17+
System.out.println(solve(input));
18+
}
19+
}

0 commit comments

Comments
 (0)