# Factorials!

If you haven’t caught the Numberphile video series over on YouTube, you don’t know what you are missing. These short videos by Dr. James Grime and Brady Haran provide brief, simple-to-grasp explanations of a variety of somewhat sophisticated mathematical topics. For example, yesterday’s new video covered some territory to which I had not really given any thought in years: the fact that 0! is equal to 1.

“You’ve broken maths, Brady. Stop that!”

Did you follow that? Let’s recap.

Recall that the factorial of a number “n” (denoted as n!) is the product of that number with all of the positive integers smaller than that number. In other words 5! = 5 x 4 x 3 x 2 x 1, 3! = 3 x 2 x 1, and so forth. In more formal mathematical notation, this is represented by

$\displaystyle n! = \prod_{k=1}^n k$.

An alternative definition (which will come in handy a little later) is this:

$\displaystyle n! = \begin{cases} 1 & \mbox{if } n \equiv 0 \\ (n-1)! \times n & \mbox{if } n > 0. \end{cases}$

But 0! = 1? Really? After all, 0 times… Er, wait a minute. There are no positive integers less than zero. That seems to make the first definition fall apart. As for the second definition, that seems a little ad hoc.

In the video, Dr. Grime takes two approaches to explaining this. The first one comes across as a bit of hand-waving, and basically involves a variant of the second definition above for calculating how factorials are calculated. He starts off with the example of the written-out form of 5!:

$\displaystyle 5! = 5 \times 4 \times 3 \times 2 \times 1 = 120$

He then points out the following relationship between 5! and 4!:

$\displaystyle 4! = \frac{5!}{5} = \frac{120}{5} = 24$

So far, so good. Continuing this pattern:

$\displaystyle 3! = \frac{4!}{4} = \frac{24}{4} = 6$
$\displaystyle 2! = \frac{3!}{3} = \frac{6}{3} = 2$
$\displaystyle 1! = \frac{2!}{2} = \frac{2}{2} = 1$
$\displaystyle 0! = \frac{1!}{1} = \frac{1}{1} = 1$

Arooh? If you think about it for a bit, it becomes apparent that this relationship:

$\displaystyle n! = \frac{(n+1)!}{(n+1)}$

is really just a subtle re-arrangement of the second definition we gave above (although this is never explicitly mentioned in the video). Looks like we are good on that count.

(The video goes on to demonstrate that this pattern breaks for taking the factorial of -1. The result is division by zero, which is undefined.)

But what about the first definition? Well, that is actually covered (with a bit of hand-waving) in the video. Dr. Grime points out that one of the key usages of the factorial is to calculate the number of ways that a given collection of things (whether they are numbers, coins, dice, colors…whatever) can be re-arranged. In other words, the factorial gives the number of permutations of the ordering of a set. Three objects can be arrange in six ways, hence 3! = 6. One object can be arranged one way, so 1!=1. But zero objects? Well, now we are talking about how many ways we can arrange a collection of nothing. Basically, there is only one arrangement of a collection of nothing.

In other words, we aren’t taking the factorial of the number zero. We are calculating the permutations of the null set. Which is one. Mathematically, we are taking advantage of a convention used by mathematicians of regarding the product of no numbers at all as always being equal to 1. This is also referred to as the empty product.

# But Wait, There’s More

The video could have ended there, but then something happened that I didn’t really see coming in a discussion targeting a general audience. Dr. Grime introduced the Gamma function, something which crops up pretty frequently in higher math. Essentially, the Gamma function generalizes the concept of the factorial to non-integers, with the argument shifted by one such that

$\displaystyle \Gamma(n)=(n-1)!$

In fact, the Gamma function extends the concept of factorials even to negative numbers, except for the negative integers, and, by analytic continuation, across the complex plane. The Gamma function is defined as follows:

$\displaystyle \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}\mathrm{d}t.$

This function is undefined for negative integers and the origin.

I won’t delve at this time into the derivation or uses of this function (although I should at some point); but, for the moment, suffice it to say that it was the creation of Leonhard Euler, the Greatest Mathematician Who Ever Lived™.  (Seriously, the only other folks who even come close are Carl Friedrich Gauss, David Hilbert, Bernhard Riemann, and, of course, Euclid.)