문제 : http://jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=589&sca=2070


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
 
long long Factorial(long long parNum)
{
 
    std::cout << parNum << "! = ";
    if (parNum == 1)
    {
        std::cout <<1<< std::endl;
        return 1;
    }
    std::cout << parNum << " * " << parNum - 1 << "!" << std::endl;
 
    return parNum * Factorial(parNum - 1);
 
 
}
 
int main()
{
    int nTmp;
    std::cin >> nTmp;
    
    
    std::cout << Factorial(nTmp) << std::endl;
 
 
 
    return 0;
}
cs

+ Recent posts