[boj] (b3) 10872 팩토리얼

강신현·2022년 4월 1일
0

✅ 재귀

문제

링크

코드

#include <iostream>

using namespace std;

int factorial(int N)
{
    if (N <= 1)
        return 1;
    else
        return N * factorial(N - 1);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int N;
    cin >> N;

    cout << factorial(N);

    return 0;
}
profile
땅콩의 모험 (server)

0개의 댓글