File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ # [ Bronze V] 팩토리얼 - 10872
2
+
3
+ [ 문제 링크] ( https://www.acmicpc.net/problem/10872 )
4
+
5
+ ### 성능 요약
6
+
7
+ 메모리: 12832 KB, 시간: 108 ms
8
+
9
+ ### 분류
10
+
11
+ 구현(implementation), 수학(math), 조합론(combinatorics)
12
+
13
+ ### 문제 설명
14
+
15
+ <p >0보다 크거나 같은 정수 N이 주어진다. 이때, N!을 출력하는 프로그램을 작성하시오.</p >
16
+
17
+ ### 입력
18
+
19
+ <p >첫째 줄에 정수 N(0 ≤ N ≤ 12)이 주어진다.</p >
20
+
21
+ ### 출력
22
+
23
+ <p >첫째 줄에 N!을 출력한다.</p >
24
+
Original file line number Diff line number Diff line change
1
+ import java .util .Scanner ;
2
+
3
+ public class Main {
4
+ public static void main (String [] args ) {
5
+ Scanner sc = new Scanner (System .in );
6
+ int n = sc .nextInt ();
7
+ int result = factorial (n );
8
+
9
+ System .out .println (result );
10
+ }
11
+
12
+ public static int factorial (int n ) {
13
+ if (n == 0 ) {
14
+ return 1 ;
15
+ }
16
+ return n * factorial (n - 1 );
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments