Easy Tutorial
❮ Python File Readlines Python Func Map ❯

Python math.factorial() Method

Python math Module

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

The parameter must be a positive integer.

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

Syntax

The syntax for 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 math package
import math

# Print 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 File Readlines Python Func Map ❯