![]() |
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 Factorial of the number is calculated as below: n! = n × (n−1) × (n−2) × … × 2 × 1
To find factorial using the recursion approach follow the below approach:
C++ Program to Find Factorial Using RecursionThe below program finds a factorial of a given number using recursion. C++
Output
Factorial of 5 is 120 Time Complexity: O(N) |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |