Study hard

(c++)백준 10872번: 팩토리얼 본문

백준/여러가지 문제들

(c++)백준 10872번: 팩토리얼

Nimgnoej 2020. 6. 18. 14:04

https://www.acmicpc.net/problem/10872

 

10872번: 팩토리얼

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

www.acmicpc.net

[풀이]

팩토리얼 : 그 수보다 작거나 같은 모든 양의 정수의 곱

 

#include <iostream>
using namespace std;

int N;

void solution() {
	cin >> N;
	int Factorial = 1;
	for (int i = 2; i <= N; i++) {
		Factorial *= i;
	}
	cout << Factorial << endl;
}

int main() {
	solution();
	return 0;
}