- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

When it is required to find the factorial of a number without using recursion, the ‘while’ loop can be used.

Below is a demonstration for the same −

my_num = int(input("Enter a number :")) my_factorial = 1 while(my_num>0): my_factorial = my_factorial*my_num my_num=my_num-1 print("The factorial of the number is : ") print(my_factorial)

Enter a number :7 The factorial of the number is : 5040

- The input number is takne from the user.
- A variable is assigned to 1.
- It is checked to see for being 0.
- If not, it is multiplied by the previous value in the variable.
- It is assigned to the same variable.
- This is done until the number reaches 0.
- It is then displayed as output on the console.

- Related Questions & Answers
- C++ Program to Find Factorial of a Number using Recursion
- Java program to find the factorial of a given number using recursion
- Python Program to Find the Sum of Digits in a Number without Recursion
- How to Find Factorial of Number Using Recursion in Python?
- Write a Golang program to find the factorial of a given number (Using Recursion)
- Factorial program in Java without using recursion.
- C++ program to Calculate Factorial of a Number Using Recursion
- Python program to find factorial of a large number
- 8085 program to find the factorial of a number
- 8086 program to find the factorial of a number
- Python Program to Find the Fibonacci Series without Using Recursion
- Python Program to Find the Length of the Linked List without using Recursion
- How to Find the Factorial of a Number using Python?
- Python Program for factorial of a number
- C++ Program to Find Factorial of a Number using Iteration

Advertisements