C++ Programming Code Examples C++ > Recursion Code Examples Program to Find Factorial of a Number using Recursion Program to Find Factorial of a Number using Recursion This C++ Program demonstrates the the computation of Factorial of a number using Recursion. #include <cstring> #include <iostream> #include <cstdlib> #define ll long long using namespace std; /* Find Factorial of a Number using Recursion */ ll fact_recur(int n) { if (n == 0 || n == 1) return 1; else return n * fact_recur(n - 1); } /* Main */ int main() { int n; while (1) { cout<<"Enter integer to compute factorial(0 to exit): "; cin>>n; if (n == 0) break; cout<<fact_recur(n)<<endl; } return 0; }