06Maths

Prime numbers

Prime numbers are the numbers that cannot be split into smaller whole numbers. Open the five drawers of this cabinet to strike them out, build them from dots, see why there is no last one, and why they protect secrets.

Contents

This cabinet has five drawers. Each one holds a single idea about prime numbers and one thing to try. Pull the drawers open in any order.

A prime number is a whole number bigger than 1 that can only be divided by 1 and by itself. 7 is prime. 8 is not, because 2 times 4 is 8.

Strike outFind every prime below 100 by crossing out the rest.

Drawer one

More than 2,000 years ago a Greek scholar called Eratosthenes described a way to find primes without dividing anything. Write the numbers down. Take the smallest one that is not crossed out and circle it. Cross out all of its multiples. Repeat.

Click the smallest number that is not struck out. Four rounds are enough. You can stop at 7: the next prime is 11, and 11 times 11 is 121, which is already past 100. Any number below 100 that can be split has a factor of 2, 3, 5 or 7.

Done: every number that is left is a prime. There are 25 of them below 100.

RectanglesLay out dots in a rectangle and see which numbers only make one.

Drawer two

Take 12 dots. You can lay them out as a rectangle in three ways: 1 by 12, 2 by 6 and 3 by 4. Take 13 dots and there is only one way: a single row.

That is what prime means. A prime number of dots makes only the single row. Every other number above 1 makes at least two rectangles, and is called composite.

Keep splitting the sides until nothing splits any more and you are left with primes: 12 is 2 × 2 × 3. Every whole number above 1 gets exactly one such list, apart from the order. This is why 1 does not count as a prime.

12 dots

1 × 12
2 × 6
3 × 4

13 dots

1 × 13

12 dots make 3 rectangles, so 12 is composite: 12 = 2 × 2 × 3. 13 dots make only 1, so 13 is prime.

No last primeBuild a number that your list of primes cannot hold.

Drawer three

Do the primes ever stop? Euclid showed that they do not, in a proof that is more than 2,000 years old. Take any list of primes. Multiply them all together and add 1.

Divide the new number by any prime on your list and you always get a remainder of 1, so none of them divides it. So the new number is a prime that is not on your list, or it splits into primes that are not on your list. Either way your list was missing something.

Pick a list and see what turns up.

Your list of primes

  1. Multiply them all2 × 3 × 5 × 7 × 11 × 13 = 30,030
  2. Add 130,031
  3. Split it into primes59 × 509
  4. Leftover when you divide30,031 ÷ 2 leaves 1, 30,031 ÷ 3 leaves 1, 30,031 ÷ 5 leaves 1, 30,031 ÷ 7 leaves 1, 30,031 ÷ 11 leaves 1, 30,031 ÷ 13 leaves 1

Neither 59 nor 509 is on your list. Your list was missing primes.

Thinning outSlide up the number line and watch the primes get rarer.

Drawer four

There are 25 primes below 100, so about 1 number in 4 is prime. Below 1,000 there are 168 (about 1 in 6). Below a million there are 78,498 (about 1 in 13).

Primes get rarer as you climb, but slowly, and they never stop. Near a number n, about 1 number in ln(n) is prime. Here ln is the natural logarithm, a key on most calculators. This is the prime number theorem, and it describes an average: the real primes do not follow a timetable.

Slide up the number line. The window shows the 100 numbers that end at your number. Primes are lit.

The window shows 901 to 1,000. 14 of the 100 numbers are prime: 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997.

Easy one wayMultiply two primes in a blink, then try to undo it.

Drawer five

Multiplying two primes is quick, even when they are big. Going back is the hard part: given the answer, find the two primes. The plainest method is to try dividing by 2, then 3, then 5 and so on.

Make a number below, then ask your browser to split it again. Watch how the number of tries grows.

Each time the number gets 2 digits longer, the tries grow about 10 times. Some of the codes that protect data online rely on this gap. They use primes with hundreds of digits. A 2048-bit number of this kind (called RSA-2048) has 617 digits, and trying every divisor would take about 10 to the power 308 tries (a number with 309 digits). Faster methods exist, but this number has never been split.

Press “Make a number”. Two primes will be multiplied.

 

Tries needed, from your own splits. The bars use a log scale: each step along is 10 times more tries.
DigitsTries
6 digitsnot tried yet
8 digitsnot tried yet
10 digitsnot tried yet
12 digitsnot tried yet
14 digitsnot tried yet
617 digitsabout 10 to the power 308 tries

This drawer needs a script. The idea: multiplying two primes takes one step, but splitting the answer takes about 10 times more tries for every 2 extra digits.

Key takeaways

  1. A prime is a whole number above 1 that only divides by 1 and itself. 1 is not prime.
  2. Every whole number above 1 splits into primes in exactly one way, apart from the order.
  3. There is no last prime. Euclid’s trick builds a new one from any list.
  4. Primes thin out as numbers grow: near n, about 1 number in ln(n) is prime. This is an average, not a timetable.
  5. Multiplying primes is easy and splitting the product is hard. Codes that protect data online lean on that gap.

Sources

Most of these sites could not be opened while this page was written, so the facts were checked through search results that quote them. The counts of primes (25, 168, 1,229, 9,592, 78,498), the 30,031 example, the 41,024,320 digit prime and the 617 digits of RSA-2048 each appeared in at least two places. The tools are toys made for this page, and nothing on it is security advice.