Program to find factorial of number using function

In Python, we can find the factorial of number using function.

Program
Def fact(n):
if n==1:
return n
else:
return n*fact(n-1)

num=int(input("Enter a number"))
if num<0:
print("Factorial does not exist for negative")
elif num=0:
print (The factorial of 0 is 1")
else:
print("The factorial of",num,"is", fact(num))

Leave a Reply