"To understand the word recursion see the word recursion."
This is a standing joke at most engineering schools and it explains what it is in a very short way. Recursion is a mathematical concept. Let's explain it a bit more. The official definition says the following:
Recursion is the process a procedure goes through when one of the steps of the procedure involves invoking the procedure itself. A procedure that goes through recursion is said to be 'recursive'.
Ok, what does that mean in human speak? It says that at some point in running our function, we will call ourselves. This means we have a function that looks something like this:
function something() {
statement;
statement;
if(condition) {
something();
}
return someValue;
}
We can see that the function something() at some point in its body calls itself. A recursive function should...