python program to find factorial of a number

in this tutorial, we will learn python program to find factorial of a number without recursion.the user will give input as a number and program will give an output as the factorial of that number.

what is factorial

the factorial of a  number is denoted by n! , it is the product of all positive integers less than or equal to n. For example,

the factorial of 5 is

5!=5*4*3*2*1=120

the factorial of 6 is

6*5*4*3*2*1=720

Note- Factorial of 1 is 1 and facorial of 0 is also 1

python program to find factorial of a number

'''python program to find factorial of a number'''
''' input'''
n=int(input("input number:-")) 
f=1
'''factorial''
while(n>0):
    f=f*n
    n=n-1
'''print'''
print("Factorial of given number is:- ")
print(f)

logic to find python program to find factorial of a number

    1. user input will store in variable n.
    2. variable f will initialize with
    3. a loop will execute and calculate the factorial and sore in variable f
    4. loop will terminate when the value of n is zero
    5. print the output
Example 1- 
input number- 5
Factorial of given number is:- 120

Example 2- 
input number- 6
Factorial of given number is:- 720

Example 3-
input number- 4
Factorial of given number is:- 24

Example 4- 
input number- 0
Factorial of given number is:- 1
python program to find factorial of a number
output

you may also like this…….


python program to calculate compound interest

Python Program to Calculate Simple Interest using function


 

Leave a Reply

Your email address will not be published. Required fields are marked *