We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8eb1d16 commit 0c2e8eaCopy full SHA for 0c2e8ea
java/inflearn/problemsolving/p07_recursive_tree_graph/P07_03_팩토리얼.java
@@ -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