백준 알고리즘 기초/수학
[백준][수학]팩토리얼
코딩고치
2019. 9. 11. 01:52
C/C++ 책의 재귀함수의 예제로 나오는 팩토리얼 구하기.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <iostream>
using namespace std;
int Factorial(int n)
{
if (n == 0)
return 1;
else
return n * Factorial(n-1);
}
int main(void)
{
int n;
cin >> n;
cout << Factorial(n) << '\n';
return 0;
}
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |