Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Not only can a handler call other handlers, but it can also call itself! When a handler does that, it is called a recursive handler. Recursion is often a suitable choice for problems that can be solved by applying the same solution to subsets of the problem. Examples might be in the evaluation of parenthesized expressions, processing the elements of a list, or enumerating the contents of a folder, which itself might contain subfolders.
Perhaps the most commonly used illustration of recursion is in the calculation of factorials. The factorial of a positive integer n, written n!, is the product of the integers from 1 through n, inclusive. So the factorial of 5, or 5!, is calculated like this: