The factorial function (along with the fibonacci series) is a common computer science example of recursion. For the recursive definition, consider the following:

f(n)=n*f(n-1)
and
f(0)=1.

For n negative, the factorial is usually undefined, but see also Euler Gamma Function for further info (the 'factorial of a negative integer' is always undefined, however 'factorials' of nearly all real numbers are defined using the gamma function). Another form of the above definition is the following:

         n
       -----
        | |
f(n) =  | |  i
        | |
        i=1

The capital pi symbolizes multiplication, just as a capital sigma denotes a sum. When written out, the above looks like 1*2*3*...*(n-1)*n. Here it must be explicitly stated that f(0)=1.


Reasons that f(0)=1 for f(n)=n!: "It all works out better!"

  • The nth derivative of xn is f(n)=n! (for n in the integers). Therefore, since the zeroeth (sp?) derivative of x0 is x0=1 (for all x not 0), 0!=1.
  • f(n)=Gamma(n+1). Therefore, f(0)=Gamma(1)=1.
  • The binomial theorem requires 0!=1 for consistency.
  • (as jrn points out) (x+1)!=x!(x+1), so x!=(x+1)!/(x+1). Therefore, 0!=(0+1)!/(0+1)=1!/1=1.
  • (See also 0! for more info.)

If you have any other reasons, please /msg me.


Stirling's Formula says that n! is approximately nn*e-n. This is very cool, *if* it's reasonably accurate.