xxxxxxxxxx
function loop(x) {
if (x >= 10) // "x >= 10" is the exit condition (equivalent to "!(x < 10)")
return;
// do stuff
loop(x + 1); // the recursive call
}
loop(0);
xxxxxxxxxx
The process in which a function calls itself directly or indirectly
is called recursion.
// Recursive Addition
f(n) = 1 n = 1
f(n) = n + f(n-1) n > 1
xxxxxxxxxx
The idea of recursion is that instead of conquering the problem top to bottom
for graph/tree or start to end for array/string in normal for/while loops,
in recursion you conquer the problem from bottom to top or end to start.
What's before the recursive call(s) gets executed going top to bottom
or start to end and what's after the recursive call(s) gets executed
going bottom to top or end to start.
xxxxxxxxxx
Looking for the meaning of recursion ?
Click On This Link Right Here >>> https://www.google.com/search?q=recursion