#Practical No. - 1: WAP in Python to find the factorial of a number using function
def fact(n):
f=1
while(n>0):
f=f*n
n=n-1
return f
n=int(input("Enter a number to find the factorial: "))
if(n<0):
print("Factorial of -ive number is not possible")
elif(n==0):
print("Factorial of 0 is 1")
else:
factorial=fact(n)
print("Factorial of ",n," is =",factorial)
No comments:
Post a Comment