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
Did you mean: recursion //A google easter egg for recursion
function multiply(arr, n) {
if (n <= 0) {
return 1;
} else {
return multiply(arr, n - 1) * arr[n - 1];
}
}
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);