Java Reference
In-Depth Information
cursive method is a statement that executes a call to itself. Recursion is a powerful control
mechanism.
The classic example of recursion is the computation of the factorial of a number. The
factorial of a number N is the product of all the whole numbers between 1 and N . For ex-
ample, 3 factorial is 1 × 2 × 3, or 6. The following program shows a recursive way to com-
pute the factorial of a number. For comparison purposes, a nonrecursive equivalent is also
included.
Search WWH ::




Custom Search