C++ Programming Code Examples C++ > Recursion Code Examples C++ recursion program: Factorial C++ recursion program: Factorial #include <iostream> using namespace std; //Factorial function int f(int n){ /* This is called the base condition, it is very important to specify the base condition in recursion, otherwise your program will throw stack overflow error. */ if (n <= 1) return 1; else return n*f(n-1); } int main(){ int number; cout<<"Enter a number: "; cin>>number; cout<<"Factorial of entered number: "<<f(number); return 0; }