Combinatorics: the mathematics of counting possibilities

Combinatorics is the part of mathematics that answers one deceptively simple question: how many? How many ways can a class line up, how many lottery tickets share a jackpot, how many hands are shaken at a crowded party. The surprise is that almost every counting problem you’ll meet reduces to one of three tools — factorials, permutations, and combinations — and once you can tell them apart, problems that look impossible shrink to a single line of arithmetic.

It pays off well beyond puzzles. The same counting rules sit underneath probability, coding and cryptography, and large parts of computer science. Knowing whether order matters, and whether repeats are allowed, is usually the whole battle.

Where counting became its own mathematics

Counting problems are ancient — mathematicians in India, the Arab world, and Greece studied them long before the field had a name. It sharpened into a discipline through the work of figures like Blaise Pascal, Jacob Bernoulli, and Leonhard Euler, then grew again across the nineteenth and twentieth centuries alongside graph theory and famous puzzles such as the four-colour theorem. The reach is wide: combinatorics feeds straight into probability, cryptography, and the study of networks.

Factorials: counting the orders of everything

Start with the simplest case — putting things in order. Three pupils on three chairs can be seated six ways. Push that to six pupils and the count is already 720, and listing them by hand stops being realistic. The pattern is clear if you fill the chairs one at a time. With four pupils and four chairs, four people could take the first seat, three remain for the second, two for the third, and one for the last: 4 × 3 × 2 × 1 = 24 arrangements. Multiplying every whole number down to one is so common it earns its own symbol, the factorial, written “!”. So 5! means 5 × 4 × 3 × 2 × 1, and n people can be ordered in n! ways.

The numbers grow violently. Ask how many ways 23 children could sit on 23 chairs and the answer is 23!, which is about 25,852,016,738,884,976,640,000 — nearly 26 sextillion arrangements. A class testing them at four lessons a week across 52 weeks a year would need roughly 124 quintillion years to get through every seating. That’s billions of times longer than the universe has existed. Factorials are mathematics’ clearest warning that “just try them all” is almost never a plan.

Permutations: when there aren’t enough chairs

Factorials assume the chairs and the people match. Often they don’t — you have more candidates than seats. Suppose two of three pupils sit while one stays standing. You still fill seats one at a time: three choices for the first chair, two for the second, and you simply stop early. Place 7 students on 3 chairs and there are 7 × 6 × 5 = 210 ways.

That “stop early” is captured cleanly with factorials. The product 7 × 6 × 5 is the same as 7! divided by 4!, because the 4 × 3 × 2 × 1 cancels. In general, arranging n objects in m ordered positions gives nPm = n! / (n − m)! possibilities — a permutation, since order still counts.

A four-digit lock makes it concrete. If you know no digit repeats, the first position can be any of ten digits, then nine, then eight, then seven: 10P4 = 5040 codes to try. When seats and people match again, m equals n, and the formula returns n! / 0!. Defining 0! = 1 keeps everything consistent, so nPn = n!, exactly as the first problem demanded.

Combinations: when order stops mattering

Permutations care about order. Plenty of problems don’t. If you can afford three of five T-shirts you like, buying red then black is the same purchase as black then red — you only care which three you walk out with. Counting those, there are ten selections, not sixty.

Sixty is what 5P3 would give, and it overcounts. Every group of three shirts can be arranged in 3! = 6 orders, so the ordered count tallies each real choice six times. Divide it out. That’s the rule for combinations: nCr = nPr / r! = n! / (r!(n − r)!), where you pick r objects from n and ignore order.

Two party problems show the split in action. Inviting 5 friends from a class of 10 is a combination, because the guest list doesn’t care who you thought of first: 10C5 = 252 possible lists. And if 75 people each shake hands with everyone once, you’re counting pairs, which is also order-free: 75C2 = 2775 handshakes.

Pascal’s triangle and a shortcut for combinations

Lay the combinations out in rows — 0C0 on top, then 1C0 and 1C1, then 2C0, 2C1, 2C2, and onward — and a familiar shape appears: Pascal’s triangle. Every entry equals the sum of the two directly above it, which means you can build the whole structure with addition alone and read off any nCr without touching the factorial formula. The number in row n, position r — counting both from zero — is precisely nCr.

That additive rule has a name and a reason. Pascal’s identity states that nCr + nC(r+1) = (n+1)C(r+1). The cleanest way to see why is to count rather than to manipulate algebra. To choose r + 1 items from n + 1, single out one item and call it X. Either your selection includes X — then you need r more from the remaining n — or it doesn’t, and you need all r + 1 from those n. Add the two cases and you’ve counted every selection exactly once. The identity isn’t an accident of the formula; it’s the counting argument written down.

Stars and bars: counting when repeats are allowed

A subtler case is choosing with repetition. A market stall carries n kinds of fruit and you want to fill a bag with r pieces, and nothing stops you taking two apples and a banana. Order doesn’t matter, but repeats do, so plain combinations don’t fit.

The trick is to picture each bag as a row of stars and bars: r stars for the fruit you take, and n − 1 bars to split them across the n kinds. Three stars, a bar, two stars, a bar, and so on spells out how many of each kind ended up in the bag. Every valid bag is one arrangement of r stars and n − 1 bars across r + n − 1 slots, so you only have to choose which slots hold the bars: (r + n − 1)C(n − 1) selections. With five kinds of fruit and ten pieces, that comes to 14C4 = 1001 possible bags — worth a thought next time you’re standing at the produce aisle.

From counting to probability

Counting is the engine behind probability. The chance of an event is the number of outcomes where it happens divided by the total number of possible outcomes, and combinatorics supplies that total. Seat four children at random on four chairs: there are 24 orders, and any given child sits first in 6 of them, so the probability is 6/24 = 1/4 — exactly what fairness predicts.

Other cases bite harder. A postman delivers four letters to four houses at random. Every house gets its correct letter in just one of the 24 arrangements, so a perfect delivery has probability 1/24 ≈ 4.17%. The chance that every house gets the wrong letter is less obvious — it isn’t simply what’s left over — but counting the bad arrangements gives 9 out of 24, or 37.5%. The lottery is the harshest sum of all: choosing 6 numbers from 49 means 49C6 = 13,983,816 equally likely tickets. Buying 100 a week, you’d wait on average about 2,689 years to win once.

How to pick the right tool

The hardest part of a counting problem is rarely the arithmetic. It’s working out which tool you’re holding. Before reaching for a formula, ask two questions:

  • Does order matter? If it does, you’re in permutation territory; if it doesn’t, you want combinations.
  • Can items repeat? If they can, and order doesn’t matter, you probably need stars and bars rather than a plain combination.

Answer those two, and a problem that looked like it needed pages of work usually collapses to one factorial, one division, or one glance at Pascal’s triangle. That shift — from listing possibilities to counting them — is the entire point of the subject, and it’s what lets you say, with certainty and without writing a single arrangement down, just how unlikely that lottery ticket really is.