Home >>Python math Module >Python math.factorial() Method
Python math.factorial() method in python is used to returns the factorial of the number and it only accepts the positive integer number , if the value is either a negative or float – it returns "ValueError" .
For example, the factorial of 4 would be 4 x 3 x 2 x 1 = 24
Syntax:math.factorial(x)
Parameter | Description |
---|---|
x | It is required a positive integer and returns the factorial number |
import math
print(math.factorial(3))
print(math.factorial(7))
print(math.factorial(11))
import math
w = 12
x = 23
y = 5
z = 2
print("factorial of ", w, " is = ", math.factorial(w))
print("factorial of ", x, " is = ", math.factorial(x))
print("factorial of ", y, " is = ", math.factorial(y))
print("factorial of ", z, " is = ", math.factorial(z))