Python program to find factorial of a number using if-else

Python program to find factorial of a number using if-else. Create a factorials number program using the Python programming language. This program will help you easily locate factorial numbers in Python. It is a key concept in any programming language for beginners. The factorial of a natural number n is the product of positive integers less than or equal to n

num = 5
fact = 1
if num < 0:
print("fact is not for negative")
elif num == 0:
print("The fact of 0 is 1")
else:
for i in range(1,num + 1):
fact = fact*i
print("The fact of",num,"is",fact)

 

Output

The fact of 5 is 120