factorial of a number in python

Today, We want to share with you factorial in python.In this post we will show you factorial of a number in python, hear for factorial program in python without recursion we will give you demo and example for implement.In this post, we will learn about prime number in python with an example.

Python Program to Find the Factorial of a Number

given_num = 6

fact_num = 1

if given_num < 0:
    print("sorry, factorial of a number is not exist of the negative numbers.")
elif given_num == 0:
    print("Your input number is 0 or 1 for factorial")
else:
    for i in range(1, given_num + 1):
        fact_num = fact_num*i
        print("the factorial of ", given_num , "is", fact_num )    

Results:

the factorial of  6 is 1
the factorial of  6 is 2
the factorial of  6 is 6
the factorial of  6 is 24
the factorial of  6 is 120
the factorial of  6 is 720

I hope you get an idea about factorials in python using for loop.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment