C++ Program to Find Factorial of Number using Recursion
Write C++ Program to Find Factorial of Number using Recursion
// CPP Program to Find Factorial of Number using Recursion #include <iostream> using namespace std; int fact(int n) { int product = 1; if(n == 0 || n == 1 ) return n; return n * fact(n-1); } int main() { int n; cout << "Enter Number :--> "; cin >> n; long int result = fact(n); cout << n << "! = " << result; return 0; }
Output:
Enter Number :--> 6
6! = 720