Prime Numbers

The codes that protect online banking and private messages are built from enormous prime numbers — special numbers that stubbornly refuse to be broken into smaller factors. Before we can see why they are so useful, let us meet them properly.

A prime number has exactly two factors: 1 and itself, and nothing else divides into it evenly. That word exactly is doing all the work — not three factors, not one, but precisely two.

A number with more than two factors is called composite instead. Take 12: it splits into 1, 2, 3, 4, 6 and 12 — six factors in all — so it is composite. Compare that with 7, whose only factors are 1 and 7: that is a prime.

The smallest primes are 2,\; 3,\; 5,\; 7,\; 11,\; 13,\; 17,\; 19,\; \dots They never run out, but they do get rarer as the numbers grow — and there is no simple rule for when the next one will appear, which is part of what makes them so fascinating to mathematicians.

See it as rectangles

Here is the picture that makes it click. Take n dots and try to arrange them into a full rectangle with more than one row. The number of rows and the number of columns are always factors of n, because rows times columns equals the total.

So here is a test you can see: if the dots can only ever make a thin 1 \times n line, the number is prime. If they can be packed into a chunkier rectangle, it is composite.

Try it yourself. Press Refresh for a brand-new number between 2 and 20: the dots pack into the fullest rectangle they can. A single line means prime; a chunky block means composite.

Here is the same idea as an animation. Press play, then replay — each time it tries a different small number, so you watch some fill a rectangle and others fall into a single lonely row.

Two numbers everyone trips over

1 is not prime. It has only a single factor — just 1 itself — and a prime needs exactly two. So the primes begin at 2, not at 1.

And 2 is the only even prime. Every other even number — 4, 6, 8, 10, \dots — can be split into two equal rows, so it always has 2 as an extra factor and is composite. After 2, every prime is odd.

The two traps that catch everybody:

Three worked examples

a cookie You have 7 cookies and you want to lay them out in tidy equal rows on a plate. Two rows? One row gets four, the other three — not equal. Three rows? Same problem. The only way to make every row equal is one single row of seven (or seven rows of one). That "you just can't split it evenly" feeling is exactly what makes 7 prime.

an orange Now try 12 oranges in a box. Suddenly you have choices: 2 rows of 6, 3 rows of 4, or 4 rows of 3 — all perfectly even. Each arrangement shows off a different pair of factors. A number that can be boxed up so many ways is the very opposite of prime: it is richly composite.

Khan Academy explains prime numbers here: