What is a factorial (n!)
Updated on June 30, 2026 · by Rafael Rossi
The factorial of a number, written n!, is the product of every positive integer up to it. It is the operation that counts how many different ways a set can be ordered — and it is also the fastest-growing function you meet in elementary mathematics.
The definition
n! = n × (n − 1) × (n − 2) × … × 2 × 1
So 5! = 5 × 4 × 3 × 2 × 1 = 120.
There is also a recursive definition, more useful in programming: n! = n × (n − 1)!, with 0! = 1 as the base case.
What it counts
5! = 120 is exactly the number of different lines five people can form. The logic is direct: there are 5 choices for the first position, 4 for the second (one person is already placed), 3 for the third, and so on. Multiply: 5 × 4 × 3 × 2 × 1.
That is why factorials appear throughout combinatorics — permutations, arrangements, combinations and probability all depend on them.
Why 0! = 1
It looks arbitrary and is not. Two independent arguments arrive at the same value.
The combinatorial argument: n! counts the ways to order n elements. There is exactly one way to order the empty set: do nothing. Hence 0! = 1.
The consistency argument: by the recurrence, n! = n × (n − 1)!. Apply it at n = 1: 1! = 1 × 0!. Since 1! = 1, it is forced that 0! = 1 for the formula not to break. The same holds for the combinations formula, which would divide by zero if 0! were 0.
How fast it grows
| n | n! |
|---|---|
| 5 | 120 |
| 10 | 3,628,800 |
| 15 | 1.3 trillion |
| 20 | 2.4 quintillion |
| 52 | 8.07 × 1067 |
| 70 | 1.2 × 10100 |
Factorials outgrow any exponential. While 2n doubles at each step, n! multiplies by n — and n keeps rising. By 70! the result passes 10100, more than the estimated number of atoms in the observable universe (on the order of 1080).
The shuffled deck that never existed before
The most concrete illustration of that scale uses an ordinary deck. The number of possible orderings of 52 cards is 52! ≈ 8.07 × 1067.
For scale: if every person who ever lived had shuffled a deck once per second since the Big Bang, the fraction of orderings produced would be indistinguishable from zero. The practical conclusion is odd and true: any properly shuffled deck is almost certainly in an order that has never existed in history and never will again.
Where factorials show up in practice
- Probability and lotteries: the combinations formula,
C(n,k) = n! ÷ [k!(n−k)!], gives how many distinct tickets exist. - Routing. The travelling salesman problem has (n−1)!/2 possible routes. With 20 cities that is already about 6 × 1016 — which is why such problems are solved by heuristics, not brute force.
- Series and calculus. Expansions of ex, sine and cosine carry factorials in the denominator; that is what makes those terms shrink fast and the series converge.
Estimating a huge factorial: Stirling's approximation
When the exact value fits nowhere, one formula gives the order of magnitude with surprising accuracy:
n! ≈ √(2πn) × (n ÷ e)n
At n = 10 it returns 3,598,696 against the true 3,628,800 — an error of 0.83%. At n = 20 the error falls to 0.42%, and it keeps shrinking as n grows.
The simultaneous appearance of π and e in a formula that merely multiplies consecutive integers is one of the most cited coincidences in mathematics — and it is not a coincidence: it comes from approximating a sum of logarithms by an integral.
Frequently asked questions
Is there a factorial of a negative number? Not under the elementary definition. The extension of the factorial to other numbers is the gamma function, and it is undefined precisely at the negative integers.
What about a fractional factorial? Also via the gamma function. A famous result is that 0.5! = √π ÷ 2 ≈ 0.8862 — π turning up where nobody expects it.
Why does my calculator fail at 70!? Because the result exceeds what standard floating point can represent (the limit is around 1.8 × 10308, but the excess of significant digits destroys precision well before that). Programs needing large factorials use arbitrary-precision arithmetic.
What is the difference between a permutation and a combination? In a permutation order matters (a race podium); in a combination it does not (cards in a hand). Both use factorials, but a combination also divides by k!, precisely to discount the orderings that should not be counted twice.