
Functionality ◾ 79
3.3 RECURSION
Repetition may be implemented through recursion, an elegant but over-
used construct. Recursion is the denition of a function, or structure, in
terms of itself. Hallmarks of well-designed recursion require the clear
specication of terminating or base cases and well-dened means to reach
such terminating conditions.
Elementary examples of recursion include the calculation of math-
ematical terms that are themselves dened recursively. Classic examples
are calculating the Fibonacci numbers as well as factorial values. See
Example 3.14 for simple code solutions to these two problems that corre-
spond direc