What a factorial is
A factorial is a product of whole numbers counting down to 1. The notation is an exclamation mark after the number:
- 3! = 3 × 2 × 1 = 6
- 4! = 4 × 3 × 2 × 1 = 24
- 5! = 5 × 4 × 3 × 2 × 1 = 120
That is the whole definition. The symbol is shorthand so that formulas do not have to write out long chains of multiplication.
Where it comes from: lining things up
The factorial answers a simple question: in how many orders can n different things be arranged?
Take four friends and four seats in a row. Any of the 4 can take the first seat. Then 3 remain for the second seat, 2 for the third, and the last person has no choice. By the multiplication principle, the total is 4 × 3 × 2 × 1 = 4! = 24 seatings.
The same logic applies to a shuffled set of cards, a batting order or the order in which songs play. With n different items, there are n! orders.
How fast it grows
Factorials grow much faster than most people expect:
| n | n! |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 6 |
| 4 | 24 |
| 5 | 120 |
| 6 | 720 |
| 7 | 5,040 |
| 8 | 40,320 |
| 10 | 3,628,800 |
A full deck has 52 cards, so the number of possible orders is 52!. That is roughly 8 × 10^67, a number with 68 digits. It is far larger than anything you could list, which is one reason a thoroughly shuffled standard deck is very unlikely to have appeared in exactly that order before. How well a given method of mixing actually randomises the deck is a separate question, discussed under riffle shuffles.
Why 0! equals 1
It can look odd that 0! = 1. The usual reasoning is that there is exactly one way to arrange nothing: the empty arrangement. It also keeps formulas consistent. For example, choosing all n items from n should give exactly 1 way, and the formula for that only works if 0! = 1.
There is also a pattern: n! = n × (n − 1)!. Setting n = 1 gives 1! = 1 × 0!, which only holds if 0! = 1.
Cancelling in fractions
In practice you rarely compute a huge factorial in full. Fractions let most of it cancel. For example:
7! ÷ 5! = (7 × 6 × 5 × 4 × 3 × 2 × 1) ÷ (5 × 4 × 3 × 2 × 1) = 7 × 6 = 42
This is how you count ordered selections. The number of ways to give gold, silver and bronze to 3 of 7 runners is 7 × 6 × 5 = 210, which is also 7! ÷ 4! = 5040 ÷ 24 = 210.
Dividing out repeats
Factorials also handle cases where some items are identical. How many different “words” can you make by rearranging the letters of BALL? If all four letters were different, there would be 4! = 24 orders. But the two Ls are interchangeable, and swapping them does not create a new word. Each distinct word has been counted twice, so divide by 2! = 2:
4! ÷ 2! = 24 ÷ 2 = 12
The same idea applies to a hand of cards when order is irrelevant. Count every ordering and divide by the number of orderings of the hand, which is the core of the difference between permutations and combinations.
Factorials inside the combination formula
The most common appearance of the factorial in odds work is the formula for choosing k items from n when order does not matter:
C(n, k) = n! ÷ (k! × (n − k)!)
Check it on a small case: choosing 2 from 5 gives 5! ÷ (2! × 3!) = 120 ÷ (2 × 6) = 120 ÷ 12 = 10.
That same formula is behind lottery odds, the counts of possible poker hands and the entries in Pascal’s triangle. The numbers become huge quickly, so calculators and spreadsheets are typically used for larger cases.
Tips for working with them
- Cancel before multiplying. Write the factorials out only as far as they differ.
- Remember 0! = 1 and 1! = 1.
- Do not confuse n! with n × n or with n × 2. For n = 5, 5! is 120, not 25 or 10.
- Large factorials overflow many basic calculators, so use fractions where possible.
Factorials are just a compact way of describing how many ways there are to order things, and once that picture is clear the formulas that include them stop looking mysterious.