Factorial program in C++

Factorial Program in C++: Factorial of n is the product of all positive descending integers. Factorial of n is denoted by n!. For example:

Here, 4! is pronounced as "4 factorial", it is also called "4 bang" or "4 shriek".

The factorial is normally used in Combinations and Permutations (mathematics).

There are many ways to write the factorial program in C++ language. Let's see the 2 ways to write the factorial program.

  • Factorial Program using loop
  • Factorial Program using recursion

Factorial Program using Loop

Let's see the factorial Program in C++ using loop.

Output:

Enter any Number: 5  
 Factorial of 5 is: 120   

Factorial Program using Recursion

Let's see the factorial program in C++ using recursion.

Output:

Enter any number: 6   
Factorial of a number is: 720




Contact US

Email:[email protected]

Factorial
10/30