Recursion
Remember square(square(square(x))); ?
Methods can invoke other methods
Methods can also invoke themselves
- When they do, this is called recursion
Recursion is a powerful, elegant, and useful technique in programming.
- Lots of interesting problems in CS.
- It is also subject to mathematical analysis, often in the form of proof by induction. (more of this in CSC 172)