11.2. Recursion in Patterns#

In the previous section, we discuss recursion in functions, e.g. greatest common divisor using euclidean algorithm or the factorial function. In this section, we discuss recursion in patterns.

In general, recursive functions will have the following structure:

Recursive function (problem)
    if terminating condition
        may do a simple calculation;
        return;
    else:
        break problem into a smaller piece/s
        Recursive function (smaller piece/s)