파이썬 math.factorial() 메서드
예시
숫자의 계승 구하기:
#Import math Library
import math
#Return factorial of a number
print(math.factorial(9))
print(math.factorial(6))
print(math.factorial(12))
정의 및 사용
이 math.factorial()
메서드는 숫자의 계승을 반환합니다.
참고: 이 방법은 양의 정수만 허용합니다.
숫자의 계승은 지정된 숫자에서 1까지의 모든 정수를 곱한 것의 합입니다. 예를 들어 6의 계승은 6 x 5 x 4 x 3 x 2 x 1 = 720이 됩니다.
통사론
math.factorial(x)
매개변수 값
Parameter | Description |
---|---|
x | Required. A positive integer. If the number is negative, or not an integer, it returns a ValueError. If the value is not a number, it returns a TypeError |
기술적 세부 사항
반환 값: | 긍정적인 int 가치 |
---|---|
파이썬 버전: | 2.6 |