Skip to content

Commit b1e2d89

Browse files
committed
[Bronze V] Title: 팩토리얼, Time: 108 ms, Memory: 12832 KB -BaekjoonHub
1 parent 6aee688 commit b1e2d89

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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+
}

0 commit comments

Comments
 (0)