Recursion
Nov 21, 2021
In computer science, recursion is a programming technique using function or algorithm that calls itself one or more time until a specified condition is met at which time de rest of each repetition is processed from the last called to the first.
Example:
float _pow_recursion(float x, float y)
{
if (y == 0)
return (1);
if (y < 0)
return (_pow_recursion(x, y + 1) / x);
return (_pow_recursion(x, y - 1) * x);
}
In this function called “__pow__ recursion” we’ll calculate the value of a number “x” raised to a number “y”.
Suposse the value of “x” is 2 and the value of “y” is 4
Given the resolution, the final result is 16