Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.factorial() Method

Python math.factorial() Method

Python math Module Python math Module

Python math.factorial(x) The method returns the factorial of x.

The argument can only be a positive integer.

The factorial of a number is the product of all integers up to it; for example, the factorial of 6 is: 6 x 5 x 4 x 3 x 2 x 1 = 720.

Syntax

The syntax of the math.factorial() method is as follows:

math.factorial(x)

Parameter Description:

Return Value

Returns a positive integer representing the factorial of the positive integer.

Example

The following example returns the factorial of positive integers:

Example

Import the math package

import

math

Output the factorial of positive integers

print

(

math

.

factorial

(

9

)

)

print

(

math

.

factorial

(

6

)

)

print

(

math

.

factorial

(

12

)

)

Output result:


362880
720
479001600

Python math Module Python math Module