16.Write a Python program to print factorial of a given number.

Solution :- 

Static :- 

num = 5
fact = 1
if num <0:
print(“Sorry , factorial does not exist for negative number”)
elif num == 0 :
print(“The factorail of 0 is 1 “)
else:
for i in range(1,num+1):
fact = fact * i
print(“The Factorial of”,num,”is”,fact)

Output :- 

 

Dynamic :- 

num = int(input(“Enter the number :- “))
fact = 1
if num <0:
print(“Sorry , factorial does not exist for negative number”)
elif num == 0 :
print(“The factorail of 0 is 1 “)
else:
for i in range(1,num+1):
fact = fact * i
print(“The Factorial of”,num,”is”,fact)

Output :-