# Python Program to Find the Factorial of a Number Without Recursion

This is a Python Program to find the factorial of a number without using recursion.

Problem Description

The program takes a number and finds the factorial of that number without using recursion.

Problem Solution

1. Take a number from the user.
2. Initialize a factorial variable to 1.
3. Use a while loop to multiply the number to the factorial variable and then decrement the number.
4. Continue this till the value of the number is greater than 0.
5. Print the factorial of the number.
6. Exit.

Program/Source Code

Here is source code of the Python Program to find the factorial of a number without using recursion. The program output is also shown below.

```n=int(input("Enter number:"))
fact=1
while(n>0):
fact=fact*n
n=n-1
print("Factorial of the number is: ")
print(fact)```
Program Explanation

1. User must enter a number.
2. A factorial variable is initialized to 1.
3. A while loop is used to multiply the number to the factorial variable and then the number is decremented each time.
4. This continues till the value of the number is greater than 0.
5. The factorial of the number is printed.

Runtime Test Cases
```
Case 1:
Enter number:5
Factorial of the number is:
120

Case 2:
Enter number:4
Factorial of the number is:
24```

Sanfoundry Global Education & Learning Series – Python Programs.

To practice all Python programs, here is complete set of 150+ Python Problems and Solutions.

If you find any mistake above, kindly email to [email protected]