Get factorial of any number in Python Question Input = 5 Output = 1*2*3*4*5 = 120 in progress 0 Python TheDataMonk 55 years 4 Answers 670 views Grand Master 0
Answers ( 4 )
Input = int(input(“Enter number:”))
factorial=1
for i in range(1,Input+1):
factorial=factorial*i
factorial
def factorial(n):
if n==0 or n==1:
return 1
else:
ans=1
for i in range(1,n+1):
ans*=i
return ans
if __name__==’__main__’:
n=int(input(“Enter a number”))
print(“the factorial of the number is”,factorial(n))
def factorial(x):
y=[]
while x>1:
y.append(x)
x=x-1
product=np.product(y)
print(product)
factorial(4)
Output: 24
input = 6
fact=1
for i in range(1,input+1):
fact=fact*i
print(fact)