Computing factorials is an example of the more general problem of computing the product of a sequence of numbers:
p0 * p1 * p2 * ... * pn
A nice property of this sort of problem is that it can be decomposed:
if we split the sequence of numbers up into all those pi
with 0 <= i < k and pj
with k <= j < n for some k,
then we can compute separately the product of the pi
and the product of the pj, and then multiply the two
results together to obtain the product of the entire sequence
(an example of divide-and-conquer).
If k is chosen such that k = 0 or
k = n, then either the first or the second sequence
will be empty (and the other will consist of the entire sequence).
Obviously this isn't particularly effective as a way of dividing and
conquering, but consideration of such a case is often useful for:
reasoning about correctness, dealing with extreme cases (for example, if
k or n are to be input), and initialising
loops that use divide-and-conquer techniques.
The most coherent choice for the product of the empty sequence is 1,
because for any number x,
1 * x = x = x * 1
(we say that 1 is an identity of multiplication).
For similar reasons, the sum of the empty sequence of numbers is
taken to be 0.