Write a program to find the factorial of a number provided by the user.

 Q. Write a program to find the factorial of a number provided by the user.

Code:-

factorial=1
num = int(input("Enter the number:"))
if  num < 0:
  print("No factorial exists.")
elif num == 0:
  print("The factorial of 0 is 1.")
else:
  for i in range(1,num+1):
    factorial = factorial*i
  print("The factorial of",num,"is",factorial)

Output:-


CASE - 1👆

CASE-2👆


CASE - 3👆


Comments