Python Tutorial Python Advanced Python References Python Libraries

Python math - factorial() Function



The Python math.factorial() function returns the factorial of a given number.

Syntax

math.factorial(x)

Parameters

x Required. Specify the number.

Return Value

Returns the factorial of a given number.

Example:

In the example below, factorial() function is used to calculate the factorial of a given number.

import math

print(math.factorial(3))
print(math.factorial(10))
print(math.factorial(20))

The output of the above code will be:

6
3628800
2432902008176640000

❮ Python Math Module