Counting, Permutations and Combinations
Product and sum rules, permutations with and without repetition, combinations, and multinomial coefficients.
Counting, Permutations and Combinations
Intuition first
When every outcome is equally likely, a probability is just a fraction: favourable outcomes divided by total outcomes. So computing the probability is counting, and every mistake in this lesson becomes a mistake in every probability that follows.
Two questions settle almost every counting problem:
- Does order matter? "ABC" and "CBA" — the same selection or different ones?
- Can things repeat? Once used, is an item gone?
Answer those two and the formula follows mechanically. Almost all errors come from answering them wrongly, not from arithmetic.
The two fundamental rules
Multiplication rule. If a task splits into independent stages with choices, the total number of outcomes is
Addition rule. If a task can be done in one of mutually exclusive ways, with options in case , the total is
| Symbol | Meaning | Read aloud |
|---|---|---|
| n! | n factorial — the product 1 × 2 × … × n, with 0! = 1 | n factorial |
| P(n, r) | Permutations: ordered selections of r from n | n permute r |
| C(n, r) | Combinations: unordered selections of r from n | n choose r |
| nCr or (n r) | Alternative notation for combinations | n choose r |
The four cases
| Order matters | Order does not matter | |
|---|---|---|
| No repetition | ||
| Repetition allowed |
Permutations
Arranging items from distinct items, order significant:
The reasoning is the multiplication rule: choices for the first position, for the second (one is used up), and so on for positions.
Combinations
Why combinations divide by r!Advanced
Count ordered selections first: .
Now notice that every unordered selection of items was counted multiple times — once for each way of ordering those items, which is ways.
So the ordered count is exactly times the unordered count:
Dividing by removes the over-counting. This "count with order, then divide by the over-count" technique solves a large fraction of harder counting problems.
Two identities worth knowing by sight:
Permutations with repeated items
Arranging items where are identical of one type, of another, and so on:
This is the multinomial coefficient, and it is the same divide-by-the-over-count idea: swapping two identical letters produces no new arrangement.
Solved problem 1 · Arrangements of a word with repeats
How many distinct arrangements are there of the letters in STATISTICS?
Step 1 — count letters and their multiplicities
STATISTICS has 10 letters:
Check:
Step 2 — apply the multinomial coefficient
Step 3 — evaluate
Answer
distinct arrangements.
Solved problem 2 · A committee with constraints
A department has 7 men and 5 women. How many 4-person committees contain at least one woman?
Step 1 — total committees with no constraint
Order does not matter and nobody serves twice, so this is a combination:
Step 2 — use the complement
"At least one woman" has many cases (1, 2, 3 or 4 women). Its complement has exactly one: no women, i.e. all 4 chosen from the 7 men.
Step 3 — subtract
Step 4 — verify by direct enumeration
Summing the four cases as a check:
Answer
committees. The complement route needed one binomial coefficient; direct enumeration needed four.
Combinations with repetition
Choosing items from types, repetition allowed, order irrelevant — how many ways to pick 6 doughnuts from 4 varieties?
The stars and bars argumentAdvanced
Represent a selection as stars divided into groups by bars. Six doughnuts from four varieties, taking 3 of the first, 0 of the second, 2 of the third and 1 of the fourth:
***||**|*Every arrangement of 6 stars and 3 bars corresponds to exactly one selection, and every selection to exactly one arrangement. So we are counting arrangements of symbols where are stars:
The bijection is the whole argument — once you see that a selection is a star-and-bar string, the formula is just the multinomial count.
Counting in code
from math import comb, perm, factorial
print(f"P(8,3) = {perm(8, 3)}") # 336 — medals, order matters
print(f"C(52,5) = {comb(52, 5):,}") # 2,598,960 — poker hands
print(f"STATISTICS = {factorial(10) // (factorial(3)*factorial(3)*factorial(2)):,}")
print(f"doughnuts = {comb(6 + 4 - 1, 6)}") # 84 — stars and bars
# Verify Pascal's rule for a few values.
assert all(comb(n, r) == comb(n-1, r-1) + comb(n-1, r)
for n in range(1, 20) for r in range(1, n))
print("Pascal's rule verified")Exercise 1
From a standard 52-card deck, how many 5-card hands contain exactly 2 aces?
Show solutionHide solution
Split the choice into two independent stages and multiply.
Choose 2 of the 4 aces:
Choose the remaining 3 cards from the 48 non-aces:
By the multiplication rule:
As a probability:
The common error is choosing 3 cards from all 50 remaining, which allows a third ace and therefore counts hands with 3 or 4 aces.
Exercise 2
How many ways can 8 people be seated at a round table, if rotations are considered identical?
Show solutionHide solution
Linear arrangements of 8 people: .
At a round table each distinct seating is counted once for every rotation. With 8 seats there are 8 rotations producing the same circular arrangement, so
The standard shortcut: fix one person's seat to break the rotational symmetry, then arrange the remaining 7 freely, giving directly.
If reflections also count as identical — relevant for necklaces rather than dinner parties — divide by a further 2, giving .
Exercise 3
A password is 6 characters from the 26 lowercase letters. How many contain at least one repeated letter?
Show solutionHide solution
Total passwords, repetition allowed and order mattering:
Passwords with all distinct letters — the complement:
Subtract:
So about 46.3% of 6-letter passwords contain a repeat — a version of the birthday problem, and higher than most people guess.
Next: Inclusion–Exclusion and Pigeonhole, for counting problems where the cases overlap.