The Famous Ones

Shor's Algorithm

10 min

Multiply two big prime numbers together and you get a much bigger number. Easy.

Now go the other way. Given only the big number, find the two primes. Nobody knows how to do that quickly, and essentially all of the internet's security is built on that fact.

In 1994, Peter Shor found a way for a quantum computer to do it. This is the result that got the whole field funded.

Shor's algorithm is mostly classical
Pick arandom, < NFind period rquantum + QFTgcd(a^(r/2)±1, N)classicalFactorsor retryr odd, or the gcd is trivial → try another a
Only the shaded step needs a quantum computer. Factoring is reduced to finding the period of a·x mod N, and period-finding is what the quantum Fourier transform is unreasonably good at.

The surprise is not the quantum bit

Shor's real insight has nothing to do with quantum mechanics. It is a piece of ordinary number theory.

Pick any number a. Look at the sequence a, , ... and each time, keep only the remainder after dividing by the big number you are trying to crack.

That sequence repeats. And if you know how often it repeats, a couple of lines of school arithmetic hand you the prime factors.

So the whole problem becomes: find how often it repeats. Ordinary computers are hopeless at that. Quantum computers, as of the last lesson, are excellent at it.

The quantum step

Build up every exponent at once, work out all the remainders in one go, and look at the result. What is left behind is a pattern that repeats at exactly the interval you want.

Feed that into the rhythm-finder from the last lesson. Look. Do the arithmetic. Done.

What it would actually take

2048 bits

The size of key protecting most secure websites today

Under 1 million

Ordinary qubits needed, per a 2025 estimate by Craig Gidney

About a week

How long it would take, at that scale

That estimate has fallen sharply — the same researcher put it at 20 million qubits in 2019. The algorithms are improving faster than the hardware.

For comparison, today's largest machines have a few hundred to about a thousand qubits, and they are considerably more error-prone than those estimates assume.

Worth remembering

  • Shor cracks the math protecting most of the internet.
  • The key insight is ordinary number theory: cracking the code reduces to finding a repeat.
  • Only the repeat-finding is quantum. Picking a number and finishing off is pen-and-paper stuff.
  • The boring remainder arithmetic, not the clever part, dominates the cost.
  • Estimates have fallen to under a million qubits — still far beyond today's machines.