Calculate Factorial Using Recursion in CPP

  1. Home
  2. Tutorials
  3. CPP
  4. CPP Programs
  5. Recursion
  6. Program

Source Code

#include <iostream>

using namespace std;

int getFactorial( int );

int main(int argc, char** argv) {

int a;  // variable declaration for input
    // Taking input in variables
    cout<<"Enter First Number : ";
    //function call

return 0;

int getFactorial( int x) {
    if(x == 1)   //base condition
        return 1;
        return  x * getFactorial( x - 1 );  // recursive call


c++ program to find factorial of number using recursion


This program use recursion method for calculation of factorial. Before this we have used Loops (factorial using while loop) for same results. In this program a function named as getFactorial is written and called recursively for factoial calculation.

Login to TRACK of Comments.