Published 2020. 12. 29. 05:39
 

10872번: 팩토리얼

0보다 크거나 같은 정수 N이 주어진다. 이때, N!을 출력하는 프로그램을 작성하시오.

www.acmicpc.net

#include <iostream>
#include <vector>
using namespace std;

unsigned int facto(int n) {
	if (n == 1 || n == 0) { return 1; }
	return n * facto(n - 1);
}

auto main()->int {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	int N; cin >> N;
	cout << facto(N) << endl;
}

'Problem set' 카테고리의 다른 글

[백준] 11726: 2×n 타일링  (0) 2020.12.29
[백준] 11052: 카드 구매하기  (0) 2020.12.29
[백준] 10870: 피보나치 수 5  (0) 2020.12.29
[백준] 10866: 덱  (0) 2020.12.29
[백준] 10845: 큐  (0) 2020.12.29
복사했습니다!