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. Formally, $n! = n(n-1)(n-2)\cdots 1$ counts the number of ways to arrange $n$ distinct objects in a line, defined recursively as $n! = n(n-1)!$ with base case $0! = 1$, and factorials appear in permutation and combination formulas. 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)$, gives $n! \approx \sqrt{2\pi n}(n/e)^n$ for large $n$.

Example

$5! = 5 \times 4 \times 3 \times 2 \times 1 = 120$, and by definition $0! = 1$; factorials grow very quickly, with $10! = 3{,}628{,}800$. How many ways can $7$ books be arranged on a shelf? $7! = 5{,}040$ ways, and adding one more book multiplies possibilities by $8$: $8! = 40{,}320$. In the normal approximation to the binomial, Stirling's formula shows that $C(2n,n) \approx 4^n/\sqrt{\pi n}$ for large $n$, a result underlying the derivation of the normal distribution as a limit of the binomial distribution.

Key Insight

Factorials count the number of ways to arrange things in order: $5! = 120$ means there are $120$ different orders for $5$ things, but they grow so quickly that they become impractical to compute directly for large $n$, which is why Stirling's approximation is used in statistics and physics. The Gamma function satisfies $\Gamma(1/2) = \sqrt{\pi}$, a result connecting probability theory to geometry, and it appears in the PDF of chi-squared, t, and F distributions, all built from normal random variables and used extensively in inference.