An Introduction to Combinatorics

Clément Thiriet October 16, 2025

Combinatorics is fascinating. It's about counting. The concept and exercises are often simple to understand, but the solutions can be tricky to find. Does order matter? Are repetitions allowed?

I wanted to write a short summary for myself where I could find the main formulas and have an intuitive proof of why they work. The proofs may not be extremely rigorous, but I think they are fairly easy to understand.

In these explanations, you will mainly encounter 2 letters, nn (the total number of elements in the set) and kk (the length of the sequence you want to get). For example, if you have an alphabet with 4 letters a,b,c,da, b, c, d and you want to form a 2-letter password, then n=4n=4 and k=2k=2.

With Order, Repetition Allowed

Example: How many unique 6-letter passwords can you create? (assuming that the allowed characters are A-Za-z0-9 for a total of 62 chars) → 626=5680023558462^6 = 56\,800\,235\,584.

Formula:

nk\begin{aligned}n^k\end{aligned}

Proof: We fill the kk positions one by one. Each position have nn possible elements because repetition is allowed. By the multiplication rule, the total number of sequences we can form is:

n×n××nk elements=nk\begin{aligned}\underbrace{n \times n \times \cdots \times n}_{k \text{ elements}} = n^k\end{aligned}

\square


With Order, No Repetition

Example: How many ways can the top 3 finishers be arranged from 10 runners? → 10!7!=720\frac{10!}{7!} = 720.

Formula:

P(n,k)=n!(nk)!\begin{aligned}P(n, k) = \frac{n!}{(n-k)!}\end{aligned}

This is called a kk-permutation.

The number of nn-permutations is hence P(n,n)=n!P(n,n) = n!.

Proof: We fill the kk positions one by one. We have nn possible elements for the first position, n1n-1 for the second position (since repetition is not allowed and one element has been used)... and for the kkth element, there are nk+1n-k+1 choices. By the multiplication rule, the total number of sequences we can form is:

n×(n1)××(nk+1)=n!(nk)!\begin{aligned}n \times (n-1) \times \cdots \times (n-k+1) = \frac{n!}{(n-k)!}\end{aligned}

\square


Without Order, Repetition Allowed

Example: How many ways to choose 3 scoops of ice cream from 5 flavors (flavors can repeat)? → (73)=35\binom{7}{3} = 35.

(n+k1k)\begin{aligned}\binom{n + k - 1}{k}\end{aligned}

Proof: TODO, this one is harder. Try it on your own, I will publish it later.


Without Order, No Repetition

Example: How many 5-card hands can be drawn from a 52-card deck? → (525)=2598960\binom{52}{5} = 2\,598\,960.

(nk)=n!k!(nk)!\begin{aligned}\binom{n}{k} = \frac{n!}{k!(n-k)!}\end{aligned}

Proof: Let's define S={1,,n}S = \{ 1, \ldots, n \}. Each kk-permutation of SS arises only once as a result of these steps, done one after the other:

  1. Take kk elements inside SS (no repetition, no order, like drawing kk balls from a bag containing nn balls numbered from 11 to nn). By definition this is (nk)\binom{n}{k}.
  2. Order these kk elements. There are k!k! ways of ordering them (see kk-permutation proof above).

By the multiplication rule,

(nk)1.k!2.=P(n,k)k-permutation of S(nk)=P(n,k)k!(nk)=n!k!(nk)!\begin{aligned}\underbrace{\binom{n}{k}}_{1.}\,\underbrace{k!}_{2.} &= \underbrace{P(n,k)}_{\text{k-permutation of $S$}} \\ \binom{n}{k} &= \frac{P(n,k)}{k!} \\ \binom{n}{k} &= \frac{n!}{k!(n-k)!} \end{aligned}

\square

If you are interested and want to know more, a good reference is Introductory Combinatorics by Richard A. Brualdi.

Unrelated "promotion" PS: If you’d like to support my work and build web apps quickly without tedious setup, consider buying my template 1Server 😉.