Skip to the page
Big Numbers, Split

Make one, break oneSplit

Multiplying is cheap. Splitting is the whole problem. The box below makes a product of two primes at whatever size you like and then tries to get the primes back, with a live count of the work. Watch the wall arrive.

Make a semiprime, then split it

Trial division tries every odd number up to the square root. Pollard's rho method (1975) walks a pseudo-random path and needs about the square root of the smaller prime — the square root of the square root. At 6 digits both finish. At 12, rho finishes and trial division shows you its projection. At 20 neither finishes, and the projection is the point.

Why there are always enough primes

Making a key means finding two primes of about 309 digits. That only works because primes never run out and never get too thin. The Prime Number Theorem [6] says that near a number x, about one in every ln x whole numbers is prime — ln being the natural logarithm, a number that grows very slowly. So:

size of the numberabout one prime in every
2 digits5
5 digits12
10 digits23
20 digits46
50 digits115
100 digits230
155 digits357
308 digits709
617 digits1421

At 309 digits, one number in about 709 is prime — and only the odd ones need testing, so one in 354. Pick random numbers, test each with a fast test that can tell prime from not (Miller–Rabin, 1976–1980; certain-if-the-Riemann-Hypothesis-holds in one version, almost-certain in the one everyone uses [14]), and a prime turns up in a few hundred tries. Your browser does it below.

A 2048-bit key, made here

Two 1024-bit primes, found by the same test, multiplied. This is the shape of the key that guards most of the web.

press the button — a second or two

Why the two primes are kept apart

Fermat noticed in 1643 [2] that any odd number is a difference of two squares, a² − b², and that (a − b)(a + b) is then a factorisation. Walk a up from the square root of N and check whether a² − N is a perfect square. If the two primes are close together, a starts near both of them and the walk is short. The primes 10,007 and 10,037 give N = 100,440,259, and Fermat's walk finds them in 1 steps. Key generators keep their two primes far apart for exactly this reason, and one of the 2024 'RSA-2048 broken' papers turned out to have chosen its numbers so that the primes differed in two bits [78].

A field of teal bars of varying height with a tall amber bar every so often at a steady spacing: a^x mod N repeating.
a^x mod 143 for x from 0: the values look random until the amber bars, where the sequence comes back to 1, at a steady spacing. That spacing is the period, and reading it is the one thing a quantum computer does that a classical one cannot — see the quantum page.