Name: Anonymous 2009-04-17 3:22
As it turns out, there is nothing particularly special about the factorial function; a great many numeric functions can be defined recursively in a natural way. For example, let's think about multiplication. When you were first introduced to multiplication (remember that moment? :)), it may have been through a process of 'repeated addition'. That is, 5 × 4 is the same as summing four copies of the number 5. Of course, summing four copies of 5 is the same as summing three copies, and then adding one more -- that is, 5 × 4 = 5 × 3 + 5. This leads us to a natural recursive definition of multiplication:
Example
Example: Multiplication defined recursively
mult n 0 = 0 -- anything times 0 is zero
mult n 1 = n -- anything times 1 is itself
mult n m = (mult n (m - 1)) + n -- recur: multiply by one less, and add an extra copy
Example
Example: Multiplication defined recursively
mult n 0 = 0 -- anything times 0 is zero
mult n 1 = n -- anything times 1 is itself
mult n m = (mult n (m - 1)) + n -- recur: multiply by one less, and add an extra copy