Python Program to Find Factorial of Number Using Loop

Here you will get python program to find factorial of number using for and while loop.

Factorial of a number is calculated by multiplying it with all the numbers below it starting from 1.

For example factorial of 4 is 24 (1 x 2 x 3 x 4).

Below program takes a number from user as an input and find its factorial.

Python Program to Find Factorial of Number

Using For Loop

Output

enter a number: 5
factorial of 5 is 120

Using While Loop

Output

enter a number: 4
factorial of 4 is 24

Comment below if you have any queries related to above python factorial program.

2 thoughts on “Python Program to Find Factorial of Number Using Loop

    1. Admin Post author

      Because range(start, end) function will generate numbers from start and end-1. In above program we want to generate numbers from 1 to num, I have used num+1 that means (num+1)-1 which ultimately means num.

      Reply

Leave a Reply

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