[백준/Python] 10872 팩토리얼

재활용병·2024년 1월 22일
0

코딩 테스트

목록 보기
102/157

[백준/Python] 10872 팩토리얼


풀이 코드 및 설명

import sys
input = sys.stdin.readline

def factorial(n):
    if n == 0:
        return 1
    else:
        return n * factorial(n-1)

N = int(input())

print(factorial(N))

재귀 함수를 이용하여 팩토리얼 계산

profile
코딩 말고 개발

0개의 댓글

관련 채용 정보