Computer Science, asked by johnmathewson123, 13 days ago

Write a program in python to print the factorial of a number

Answers

Answered by priyanshusharma7047
2

Answer:

See this example:

  • num = int(input("Enter a number: "))
  • factorial = 1.
  • if num < 0:
  • print("Sorry, factorial does not exist for negative numbers")
  • elif num == 0:
  • print("The factorial of 0 is 1")
  • else:
  • for i in range(1,num + 1):
Answered by aj200260
2

Answer:

num=int(input("enter a number:"))

fact=1

if num<0:

   print("factorial does not exist for this numnber:")

elif num==0:

   print("factorial of 0 is 1")

else:

   for i in range(1,num+1):

         fact=fact*i

   print("factorial of fact is",fact)

Similar questions