Find The Factorial Of A Number | Python Program

Well, at first you need to know what is factorial.
The answer is, it is a non-negative integer. It is the product of all positive integers less than or equal to that number for which you ask for factorial. It is denoted by exclamation sign (!).
For example:- 4! = 4x3x2x1 = 24
Now, if you wondering how to do that through a python program than just observer the        
example below…

 

Code :

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):

        factorial = factorial*i

    print("The factorial of",str(num),"is",factorial)

Output :



Comments

Popular posts from this blog

TOP 10 PROGRAMMING LANGAUAGES COMMING 2021 | ARTICLE

Write a C-program to swap two number:

Print Fibonacci Series using Recursion | C program :