Definition of Recursion
What is meant by Recursion?
Answers
Answered by
4
A recursion function is one which calls itself either directly or indirectly it must halt at a definite point to avoid infinite recursion.
Answered by
9
Recursion is the process due to which a function calls itself .
EXPLANATION :
⏩ We generally call a function from outside that function . However a recursive function calls the function itself .
⏩ Recursive functions can be used effectively to calculate the factorial of a variable .
⏩ A factorial of a number is the product of all non negative and non zero integers present before the number .
⏩ An example of recursive function in C++ :
int f(int n)
{
if (n==1)
{
return 1;
}
else
{
return n*f(n-1);
}
}
⏩ Here the function f is calling itself multiple times to calculate the factorial of the number n .
Similar questions