Notice
Recent Posts
Recent Comments
«   2025/08   »
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
31
Today
Total
Archives
관리 메뉴

cyphen156

백준-재귀 27433 팩토리얼 2 본문

컴퓨터공학/알고리듬 풀이

백준-재귀 27433 팩토리얼 2

cyphen156 2025. 7. 11. 11:03

팩토리얼 2

팩토리얼 연산 재귀호출로 구성하기

제약사항

  • 0 < N <= 20

주의 사항

  • 없다.

CPP풀이

팩토리얼 2_27433.cpp

/**
 * 백준 팩토리얼 2_27433
 * 팩토리얼 연산 재귀호출로 구성하기
 * 
 * 제한사항
 *****************************************
 * 0 <= N <= 20                           *
 *****************************************
 *
 *
 *
 * 주의
 * 없다.
 * 
 * 풀이시간 5분
 */


#include <iostream>

using namespace std;

long long int recursive(long long int input);

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

    cout << recursive(N) << '\n';
    return 0;
}

long long int recursive(long long int input)
{
    if (input == 0 || input == 1)
    {
        return 1;
    }
    else 
    {
        input *= recursive(input - 1);
    }

    return input;
}

모든 예제 코드의 소스파일은 제 개인 깃허브 레포지토리에 있습니다.

 

Workspace/알고리듬 풀이 at main · cyphen156/Workspace

Studying . Contribute to cyphen156/Workspace development by creating an account on GitHub.

github.com