Advanced level

Combinatorics

The art of counting without listing. The rule of product, factorials, permutations, arrangements and combinations all answer one question — in how many ways can this be done — and the whole difficulty comes down to two decisions: does order matter, and may items repeat.

Before you start

This topic builds on earlier ideas. Before you start, it's worth working through the lessons below — they'll make everything click:

All formulas

  • Rule of product

    N=k1k2kmN = k_1 \cdot k_2 \cdot \ldots \cdot k_m

    a choice made in several independent steps — multiply the counts

  • Factorial

    n!=123n,0!=1n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot n, \qquad 0! = 1

    the product of the first n naturals; 0! equals 1 by definition

  • Permutations

    Pn=n!P_n = n!

    the number of orderings of all n items

  • Arrangements without repetition

    n!(nk)!=n(n1)(nk+1)\frac{n!}{(n-k)!} = n(n-1)\ldots(n-k+1)

    choose k out of n, order matters, nothing repeats

  • Arrangements with repetition

    nkn^k

    k times over, we choose from the same n options

  • Combinations

    (nk)=n!k!(nk)!\binom{n}{k} = \frac{n!}{k! \, (n-k)!}

    choose k out of n, order does NOT matter

  • Symmetry of combinations

    (nk)=(nnk)\binom{n}{k} = \binom{n}{n-k}

    choosing k items is the same as discarding the other n − k

Combinatorics answers the question "in how many ways?" before anyone can start listing cases. It is also a prerequisite for classical probability: to divide the number of favourable outcomes by the number of all of them, you first have to be able to count both.

The rule of product

All of combinatorics grows out of a single observation. If a choice is made in several independent steps offering k1,k2,,kmk_1, k_2, \ldots, k_m options, then the number of outcomes is:

N=k1k2kmN = k_1 \cdot k_2 \cdot \ldots \cdot k_m

The counts are multiplied, not added — because every decision in the first step can be paired with every decision in the second.

A restaurant offers 4 soups, 6 mains and 3 desserts. How many different three-course meals are there?

Factorials

The product of the first few naturals turns up so often in counting that it has its own symbol:

n!=123nn! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot n

It is read "n factorial". The first few values are worth knowing by heart:

nn01234567
n!n!1126241207205040

Mind the first column: 0!=10! = 1, by definition. An empty sequence can be arranged in exactly one way — by doing nothing — and besides, without that convention the combination formula would divide by zero.

012345670200400600800nn!12624120720n!
The first three bars are almost invisible at this scale. A factorial grows faster than any power — 10! is already over three and a half million.

That growth is a practical hint: if ten people can be ordered in 3,628,8003{,}628{,}800 ways, solving a problem by listing cases is out of the question.

Permutations

A permutation is an ordering of all nn items. The first position can be filled in nn ways, the second in n1n-1 (one item is already used), and so on:

Pn=n(n1)21=n!P_n = n \cdot (n-1) \cdot \ldots \cdot 2 \cdot 1 = n!
In how many ways can five people form a queue?

Arrangements without repetition

When only kk of the nn items are chosen but order matters, we are counting arrangements without repetition:

n!(nk)!=n(n1)(nk+1)\frac{n!}{(n-k)!} = n(n-1)\ldots(n-k+1)

The second form is the handier one to compute: it is simply kk decreasing factors starting at nn.

A club has 8 members. In how many ways can a chair, a secretary and a treasurer be chosen?

Arrangements with repetition

If items may repeat, each of the kk steps has the full nn options, so the rule of product gives directly:

nkn^k
How many four-digit PINs are there?

Combinations

When kk items are chosen out of nn and order does not matter, we have combinations:

(nk)=n!k!(nk)!\binom{n}{k} = \frac{n!}{k! \, (n-k)!}

Where does the k!k! in the denominator come from? From the fact that the arrangements counted every kk-element set k!k! times over — once for each ordering of the same items. So we divide by the number of those orderings:

(nk)=n!/(nk)!k!\binom{n}{k} = \frac{n!/(n-k)!}{k!}
In how many ways can a delegation of three be chosen out of 8 people?

Symmetry

Combinations have a property that saves a great deal of arithmetic:

(nk)=(nnk)\binom{n}{k} = \binom{n}{n-k}

Choosing kk items is, after all, the same as naming the nkn-k items left behind. So (2018)\binom{20}{18} is computed like (202)=190\binom{20}{2} = 190, rather than by writing out eighteen factors.

−10123456704812162024kC(6, k)1615201561C(6, k)
The counts of choices from a six-element set line up symmetrically: the outer bars are choosing nothing and choosing everything, and the tallest one stands exactly in the middle.

The bars add up to 64=2664 = 2^6 — the number of subsets of a six-element set, because every item is decided independently: take it or leave it.

Which formula to use

The whole difficulty comes down to two questions about the problem:

does order matter?may items repeat?formula
yes, all items are usedn!n!
yes, kk out of nnnon!(nk)!\dfrac{n!}{(n-k)!}
yes, kk out of nnyesnkn^k
no, kk out of nnno(nk)\dbinom{n}{k}

A practical test for the first question: swap two of the chosen items. If that gives a different situation, order matters.

Exercises

The five kinds of question match the five formulas in this lesson. A prompt with an exclamation mark asks straight for a factorial — mind 0!=10! = 1. Permutations for a given nn is also n!n!, only phrased in words. Arrangements without repetition and arrangements with repetition both come with nn and kk; they differ only in whether items may be taken more than once. Combinations ask for a choice of kk out of nn with order ignored — and here the symmetry is worth remembering. Every answer is a whole number.

Practice

Work through a set of exercises — they get harder as you go. At the end you'll see your score and the mistakes worth reviewing.

Exercise 1 of 8Score: 0
3! =

Common mistakes

  • Adding instead of multiplying — successive steps of a choice multiply the counts.
  • Confusing arrangements with combinations — if order does not matter, the result still has to be divided by k!k!.
  • Forgetting 0!=10! = 1 — especially in the edge cases of the combination formula.
  • Cancelling factorials by eye8!5!\tfrac{8!}{5!} is 8768 \cdot 7 \cdot 6, not 85\tfrac{8}{5} and not 3!3!.
  • Assuming repetition — whether items may repeat is decided by the problem, not by which formula is more convenient.
  • Listing the cases — beyond n=5n = 5 there are usually far too many to get through without a slip.

Formula card

Topic: Combinatorics

  • Rule of product

    N=k1k2kmN = k_1 \cdot k_2 \cdot \ldots \cdot k_m

    a choice made in several independent steps — multiply the counts

  • Factorial

    n!=123n,0!=1n! = 1 \cdot 2 \cdot 3 \cdot \ldots \cdot n, \qquad 0! = 1

    the product of the first n naturals; 0! equals 1 by definition

  • Permutations

    Pn=n!P_n = n!

    the number of orderings of all n items

  • Arrangements without repetition

    n!(nk)!=n(n1)(nk+1)\frac{n!}{(n-k)!} = n(n-1)\ldots(n-k+1)

    choose k out of n, order matters, nothing repeats

  • Arrangements with repetition

    nkn^k

    k times over, we choose from the same n options

  • Combinations

    (nk)=n!k!(nk)!\binom{n}{k} = \frac{n!}{k! \, (n-k)!}

    choose k out of n, order does NOT matter

  • Symmetry of combinations

    (nk)=(nnk)\binom{n}{k} = \binom{n}{n-k}

    choosing k items is the same as discarding the other n − k

012345670200400600800nn!12624120720n!
Factorials for n from 1 to 6. At this scale the first three bars are practically invisible — 6! is already a hundred and twenty times 3!. This is what combinatorial growth looks like.
−10123456704812162024kC(6, k)1615201561C(6, k)
The number of ways of choosing k items out of six. The picture is symmetric, because choosing k items is the same as discarding the other 6 − k; picking half the set gives the most options.

Frequently asked questions

Related articles