...

/

Direct vs. Indirect Recursion

Direct vs. Indirect Recursion

This lesson explains two different types of recursion: direct and indirect recursion.

Direct Recursion

If a function calls itself, it’s known as direct recursion. This results in a one-step recursive call: the function makes a recursive call inside its own function body.

Press + to interact
void directRecursionFunction()
{
// some code...
directRecursionFunction();
// some code...
}

Below is an example of a direct recursive function that computes the square of a number: ...