Python Program to Find the Factorial of a Number

Image result for python programming images copyright free images
Python Programming

In this article, you will learn how to find the factorial of any number in Python so let's start...


Source code ::  

num = int(input("Enter a number : "))
fact = 1
if num<0:
    print("Please enter positive number")
elif num==0:
    print("Factorial of 0 is 1")
else:
    for i in range(1,num+1):
        fact = fact*i
    print("Factorial of ",num,"is : ",fact)
    
        
Output ::  

 Enter a number : 5

Factorial of  5 is: 120



This is the program to find the factorial of any given number. If you have any doubt you can contact me via contact form I will answer you definitively.

No comments:

Post a Comment