Factorial

Statistics & Probability

The factorial of a non-negative integer n, written n!, is the product of all positive integers from 1 to n.

Formula

n! = n \times (n-1) \times (n-2) \times \cdots \times 2 \times 1

Definition

The factorial of a number (written with an exclamation mark) means multiply that number by every whole number less than it, down to 1.

Example

$5! = 5 \times 4 \times 3 \times 2 \times 1 = 120$. By definition, $0! = 1$. Factorials grow very quickly: $10! = 3{,}628{,}800$.

Key Insight

Factorials count the number of ways to arrange things in order. $5! = 120$ means there are $120$ different orders for $5$ things.

Definition

The factorial $n! = n(n-1)(n-2)\cdots 1$ counts the number of ways to arrange $n$ distinct objects in a line. Defined recursively: $n! = n(n-1)!$ with base case $0! = 1$. Factorials appear in permutation and combination formulas.

Example

How many ways can $7$ books be arranged on a shelf? $7! = 7 \times 6 \times 5 \times 4 \times 3 \times 2 \times 1 = 5{,}040$ ways. Adding one more book multiplies possibilities by $8$: $8! = 40{,}320$.

Key Insight

Factorials grow so quickly that they become impractical to compute for large $n$. Stirling's approximation $n! \approx \sqrt{2\pi n}(n/e)^n$ is used in statistics and physics for large $n$.

Definition

The factorial extends to non-integers via the Gamma function: $\Gamma(n) = (n-1)!$ for positive integers, defined by $\Gamma(z) = \int_0^\infty t^{z-1}e^{-t}\,dt$. Stirling's approximation: $\ln(n!) \approx n\ln n - n + 0.5\ln(2\pi n)$, from which $n! \approx \sqrt{2\pi n}(n/e)^n$.

Example

In the normal approximation to the binomial, Stirling's formula is used to show that $C(2n,n) \approx 4^n/\sqrt{\pi n}$ for large $n$. This result underlies the derivation of the normal distribution as a limit of the binomial distribution.

Key Insight

The Gamma function satisfies $\Gamma(1/2) = \sqrt{\pi}$, a result connecting probability theory to geometry. It appears in the PDF of chi-squared, t, and F distributions, all of which are built from normal random variables and used extensively in inference.