# Factorial program in python

• The term "Factorial" means multiplication of all the integers the given number as we want the fact of it.
• Factorial is applicable for only positive integers, for 0! it is always 0.
• Simply if we want the factorial of 3 then it is written as  3!=3*2*1
• The formula is Fact=n*(n-1)*(n-2)*.......1
• Write a python program to find the factorial of a given number without recursion and with recursion.

#### #write a python program for factorial of a given number.

num = int(input("Enter a number: "))
factorial = 1
if num < 0:
print("factorial not exist for negative numbers")
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)

• We store the number we give in the num variable and by using the if, elif, and else loop we are executing the program. if statement executes when the given condition is true and same for elif also. After the iteration, it finally returns the factorial of the number we are given.
• Normally we write as 12!=12*11*10*9*8*7*6*5*4*3*2*1=479001600

#### Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.