백준 10872 팩토리얼 / C++

이유참치·2025년 12월 15일

백준

목록 보기
131/249

문제 : 10872

풀이 point

N!을 for문을 통해 구현한다.

코드

//백준 10872, 팩토리얼

#include <iostream>

int main (){

    int N;
    std::cin >> N;
    int ans{1};
    for(int i{1}; i<=N; ++i){
        ans *= i;
    }

    std::cout << ans;

    return 0;
}
profile
임아리 - 대학생

0개의 댓글