5.5.1 How to Use Recursion

Recursion is the repeated application of a procedure or series of steps. In computer science, it is often implemented as a method that calls itself until the problem is solved, the process is complete, or the end of a list is reached.

There are two main rules when implementing recursion in code: 1) that a method calls itself in the method body, and 2) that the method must check a condition, called a "Base Case", that would allow it to stop (otherwise it could become an infinite loop and cause a StackOverflowException).