In this program, we will see how to Find The Factorial of a Number.
In this program, we are using if, elif & else condition with a for loop.
Follow the code given below:
num = int(input('Enter the number: '))
factorial = 1
if num<0:
print("Factorial doesn't exist")
elif num==0:
print("Factorial is 1")
else:
for i in range(1,num+1):
factorial = factorial*i
print("Factorial is",factorial)
-----------------
Output:
Enter the number: 8
Factorial is 40320
That's it!
Facing any issues comment down we are free to help you.
liked the content don't forget to share with your fellow mates.
No comments:
Post a Comment