by R4R Team


program-

#import numpy
import numpy as np

n=int(input("Enter any numbern"))
ans=np.product([i for i in range(1,n+1)])
print("Factorial of number is :",ans)


output-

Enter any number
5
Factorial of number is : 120

Enter any number
4
Factorial of number is : 24

Enter any number
6
Factorial of number is : 720


-In this program, we take a input of the integer number, then run loop from 1 to the given number, and make list like [1,2,3,4,5,......] then using np.product(), we multiple all elements of the list and that will be the required factorial.




Leave a Comment: