Explanation:
Recursion is when the function calls itself inside it's definition.The advantages of recursion are as following:-
#include<iostream>
using namespace std;
int factorial( int n1)
{
if (n1 == 0)
return 1;
return n1 * factorial(n1 - 1);
}
int main()
{
int no ;
cin>>no;
cout<<factorial(no)<<endl;
return 0;
}
Recursive function to find the factorial of a number.