Write a python program to find factorial of a number ?

Factorial 


When we recursively multiply number incrementing from 1 to a given number then its called factorial of that number. We use the notation ! to denote factorial. 
Factorial of 5 = 5! = 5X4X3X2X1

Code

def findFactorial(num):
    try:
        a = int(num)
        value = a
        while a>1:            
            a = a-1
            value = value*a
            print(value)
        print("Factorial of {} is {}".format(num,value))

    except:
        print("You have not entered a number")

number = input("enter a number")
findFactorial(number)

No comments:

Post a Comment

Write a python program to find factorial of a number ?

Factorial  When we recursively multiply number incrementing from 1 to a given number then its called factorial of that number. We use the no...