How to Find the Factorial of an integer with NumPy in Python
A factorial of an integer is the result of multiplying all the integers less than or equal to it in descending order.
To get the factorial of 4 four (24) we would use the following formula:
4! = 4 x 3 x 2 x 1 = 24
In Python, we can get factorials by using the numpy
package. Import it then use the np.math.factorial()
function, passing the number to calculate the factorial of as the first argument.
import numpy as np
result = np.math.factorial(4)
print(result)
24