TL;DR
Counting principles are the rules for answering "how many ways can this happen?" without listing every way. If a task has several stages and each stage has a fixed number of choices, multiply those numbers. If the order of choices does not matter, divide by the number of ways to reorder them. Almost every counting problem is one of these two moves, applied with care.
Where you'll see it: in computing the chance of a poker hand, in estimating how many passwords an attacker must try, in the coefficients of a polynomial expansion, and in the probability formulas used throughout Probability.
Intuition
A menu with two courses
Suppose a cafe offers 3 soups and 4 sandwiches, and you order one soup and one sandwich. How many meals are possible? Pick a soup (3 ways). For each soup, pick a sandwich (4 ways). Each of the 3 soups pairs with each of the 4 sandwiches, so there are meals. You never wrote the 12 pairs out. You only needed to know how many choices each stage had.
That is the whole idea of counting. We cannot always list the outcomes, because there may be billions of them. But if the structure is clear, we can count them by thinking about the stages.
Why order sometimes matters and sometimes does not
Now suppose three friends want to share a pizza, and you must choose two of them to wash the dishes. Choosing Ana then Ben is the same job as choosing Ben then Ana. Here order does not change the outcome. A different situation is a podium: gold, silver and bronze go to different people, so Ana-Ben-Cy is a different result from Cy-Ben-Ana. The first kind of selection is a combination, the second is a permutation. Most mistakes in counting come from using the wrong one.
flowchart TD
A[Selecting k items from n] --> B{Does order matter?}
B -->|Yes| C{Can an item repeat?}
B -->|No| D{Can an item repeat?}
C -->|No| E[Permutations: n times n-1 and so on]
C -->|Yes| F[n to the power k]
D -->|No| G[Combinations: n choose k]
D -->|Yes| H[Multisets: a different formula]
The math
The multiplication principle
If a procedure has stages, and stage can be done in ways regardless of what happened earlier, then the whole procedure can be done in
ways. The phrase "regardless of what happened earlier" matters. If the choices at a later stage depend on earlier ones, you must count each branch separately.
The addition principle
If a choice is one of two or more disjoint options, add the counts. Choosing a starter from 4 soups or a dessert from 3 cakes gives options for a single course. "Disjoint" means no option is also counted in another. When options overlap, you must subtract the overlap, which leads to set union and the inclusion-exclusion formula.
Factorials
The number of ways to arrange distinct objects in a line is
read " factorial". By convention . The reason is the multiplication principle: the first position has choices, the second has remaining, and so on until one object is left for the last spot.
Permutations
An ordered selection of objects from distinct objects, with no repeats, is a permutation. The count is
The first form says: take all orderings, then discard the orderings of the objects you did not pick. The second form is the one you compute by hand, with exactly factors.
Combinations
An unordered selection of objects from is a combination. Each combination of items can be arranged in ways, and each of those arrangements is a permutation. So the number of combinations is the number of permutations divided by :
This is read " choose ", and it is called the binomial coefficient. It counts subsets: the number of ways to choose a -element subset of an -element set. A useful fact is the symmetry , because choosing who goes in a committee is the same as choosing who stays out.
Pascal's rule
The binomial coefficients satisfy
To see why, fix one particular object. Either it is in the chosen subset, leaving spots for the other objects, or it is not, leaving spots. Arranging these values in rows gives Pascal's triangle, where each entry is the sum of the two above it.
Worked examples
A four-digit PIN uses the digits 0 through 9.
- Repeats allowed: each of the 4 positions has 10 choices, so PINs.
- No repeats: the first digit has 10 choices, the second 9, the third 8, the fourth 7. So .
- The restriction removes half of the PINs ( of ), so a rule forbidding repeats actually makes guessing easier for an attacker, not harder: there are only half as many codes to try.
Eight runners finish a race. Two different questions use the same eight people.
Question 1: how many ways can gold, silver and bronze be awarded?
- Order matters, and no one can win two medals. This is .
- .
Question 2: how many ways can three people be chosen for a relay team, with no roles?
- Order does not matter. This is .
- .
- Each team of 3 appears times in the 336 podiums, which is exactly the factor that divides out.
A standard deck has 52 cards, 4 of them aces. A five-card hand is dealt at random. What is the chance it contains exactly two aces?
- Total hands: .
- Choose which 2 aces: .
- Choose the other 3 cards from the 48 non-aces: .
- Favourable hands: .
- Probability: , about 4%.
The hand is counted without order, so the combinations formula is the right tool. Using permutations here would overcount each hand by .
Tradeoffs and failure modes
Counting is simple to state and easy to get wrong. The errors are almost always about structure, not arithmetic.
| Situation | Common mistake | Better approach |
|---|---|---|
| Order does not matter, but you use permutations | Each set is counted times | Divide by , or use combinations |
| Choices at a later stage depend on earlier ones | Multiplying fixed counts | Count each branch, or condition on the first choice |
| Options overlap | Adding counts and double-counting the overlap | Subtract the overlap, or use inclusion-exclusion |
| Items may repeat | Using | Use for ordered repeats, or the multiset formula for unordered ones |
| Very large | Computing fully before dividing | Cancel common factors first, as in |
A few practical habits help. First, restate the problem as a sequence of stages and ask whether the count at each stage is fixed. Second, sanity-check with a tiny case: for 3 objects, list all the outcomes and confirm your formula gives that number. Third, when a count seems too large, check whether you counted the same outcome more than once.
Counting also has limits. Exact counts become impossible to compute for huge in practice, and that is one reason probabilistic methods such as Monte Carlo sampling exist. For estimating a rare event, sampling may be cheaper than exact counting.
History
Counting problems are very old. Pingala, an Indian scholar who probably wrote around the third or second century BCE, studied the number of possible syllable patterns in Sanskrit verse, a combinatorial question about sequences. Later Indian mathematicians worked out the binomial coefficients in connection with counting meters. Persian and Chinese mathematicians also described the triangular arrangement of these numbers centuries before it became known in Europe.
In Europe, the systematic study of combinations grew from gambling. In 1654, Blaise Pascal and Pierre de Fermat corresponded about how to divide the stakes of an unfinished game of chance, a problem that required counting outcomes. Pascal wrote a treatise on the arithmetical triangle that organised these coefficients and used them in probability. Jakob Bernoulli's later work on probability, published after his death in 1713, made counting a standard tool.
The modern field, called enumerative combinatorics, grew through the twentieth century as mathematicians studied counting problems for their own sake. The basic principles in this lesson, however, have been stable for centuries.
Check yourself
QuestionState the multiplication principle in your own words. Why is it not enough when later choices depend on earlier ones?Show answer
If a procedure has stages, and each stage has a fixed number of choices regardless of earlier choices, the total number of outcomes is the product of the counts. When later choices depend on earlier ones, the count at the later stage is not fixed. You then have to split the count into branches, each with its own number of choices, and add the branch totals.
QuestionHow many three-letter codes can be made from the 26 letters A to Z if no letter may repeat? Show the product.Show answer
The first letter has 26 choices, the second 25, the third 24. The total is .
QuestionWhy does the formula for combinations divide by and not by ?Show answer
A combination of chosen items can be arranged in orders, and each of those orders is counted once in the permutation formula. Dividing by removes this overcount, leaving one count per set. The term is already in the permutation formula, to discard the unchosen items, and it appears in the combinations formula as well, but it does not explain the division.
QuestionA team of 5 must be chosen from 12 people, with one captain and one deputy chosen from the team. How many ways are there? Explain which principle you used.Show answer
First choose the captain and deputy, in order, from the 12 people: ways. Then choose the other 3 team members from the remaining 10 people, without order: . Multiply the stages: . The multiplication principle links the stages, and the combinations formula handles the unordered part.