C++ Program to Find Factorial of a Number Using Iteration Last Updated : 09 Feb, 2024 Comments Improve Suggest changes Like Article Like Report Factorial of a number n is the product of all integers from 1 to n. In this article, we will learn how to find the factorial of a number using iteration in C++. Example Input: 5Output: Factorial of 5 is 120Factorial of Number Using Iteration in C++To find the factorial of a given number we can use loops. First, initialize the factorial variable to 1, and then iterate using a loop from 1 to n, and in each iteration, multiply the iteration number with factorial and update the factorial with the new value. C++ Program to Find Factorial Using IterationThe below program shows how we can find the factorial of a given number using the iteration method. C++ // C++ program to find factorial of a number using iteration #include <iostream> using namespace std; int main() { // number n whose factorial needs to be find int n = 5; // initialize fact variable with 1 int fact = 1; // loop calculating factorial for (int i = 1; i <= n; i++) { fact = fact * i; } // print the factorial of n cout << "Factorial of " << n << " is " << fact << endl; return 0; } OutputFactorial of 5 is 120 Time Complexity: O(N), where N is the given numberAuxiliary Space: O(1) Comment More infoAdvertise with us Next Article C++ Program to Find Factorial of a Number Using Iteration T the_star_emperor Follow Improve Article Tags : C++ Programs C++ Basic Coding Problems factorial CPP Examples +1 More Practice Tags : CPPfactorial Similar Reads C++ Program to Find Factorial of a Large Number Using Recursion Given a large number N, task is to find the factorial of N using recursion. Factorial of a non-negative integer is the multiplication of all integers smaller than or equal to n. For example factorial of 6 is 6*5*4*3*2*1 which is 720. Examples: Input : N = 100Output : 93326215443944152681699238856266 2 min read C++ Program to Find Factorial of a Number Using Dynamic Programming The Factorial of a number N can be defined as the product of numbers from 1 to the number N. More formally factorial of n can be defined by function,f(n) = 1 \times 2 \times 3 \times... \ nIn this article, we will learn how to find the factorial of a number using dynamic programming in C++.Example:I 2 min read C++ Program to Find Factorial Using Recursion The factorial of a number is denoted by "n!" and it is the product of all positive integers less than or equal to n. In this article, we will learn how to find the factorial of a number using recursion in C++. Example Input: 5 Output: Factorial of 5 is 120 Factorial Using Recursion in C++The Factori 2 min read Factorial of Large numbers using Logarithmic identity Given a very large number N, the task is to find the factorial of the number using Log.Factorial of a non-negative integer is the multiplication of all integers smaller than or equal to N.We have previously discussed a simple program to find the factorial in this article. Here, we will discuss an ef 6 min read Maximum number with same digit factorial product Given a string str which represents an integer, the task is to find the largest number without any leading or trailing zeros or ones whose product of the factorial of its digits is equal to the product of the factorial of digits of str.Examples: Input: N = 4370 Output: 73322 4! * 3! * 7! * 0! = 7! * 9 min read Like