The problem it solves
Multiplying two large prime numbers is easy, and recovering them from the product is hard. RSA encryption depends on that gap. The best known classical method for factoring takes time that grows faster than any polynomial in the number of digits, so a 2048-bit RSA number stays out of reach of every computer built.
Shor showed in 1994 that a quantum computer could factor in time that grows only polynomially with the number of digits. He also gave a fast method for the discrete logarithm problem behind Diffie-Hellman, and the same approach adapts to elliptic curves. One family of algorithms therefore threatens all three of the public-key systems in everyday use.
The idea in plain words
Shor's algorithm turns factoring into a different question, which is to find how often a certain pattern repeats. Pick a number a that shares no factor with N, the number to be factored. The values of a, a squared, a cubed and so on, each taken modulo N, eventually return to 1. The number of steps before that happens is called the period, or the order of a.
If r is even, and a to the power r/2 is not equal to minus 1 modulo N, simple arithmetic turns it into factors of N. Otherwise you pick another a, and for random choices this works at least half the time. The hard part is finding r. The quantum machine puts its input register into a superposition and computes the pattern once across it, coherently. Measuring directly would give one random value and reveal nothing, so it first applies a quantum Fourier transform, which uses interference to make outcomes tied to the period far more likely. Hidden periodic structure like this is one of the few things a quantum computer is known to find much faster than a classical one. A normal computer finishes the job with a greatest common divisor, a step it can do quickly.
A worked example with 15
Take N = 15 and choose a = 7. The powers of 7 modulo 15 are 7, 4, 13 and 1, so the period is r = 4. You can check this by hand, since 7 squared is 49, which is 4 more than 45, and 7 to the fourth power is 2,401, which is 1 more than 2,400.
- The period 4 is even, so compute 7 to the power 4 divided by 2, which is 7 squared, or 49.
- Find the greatest common divisor of 49 minus 1 and 15. That is gcd(48, 15), which is 3.
- Find the greatest common divisor of 49 plus 1 and 15. That is gcd(50, 15), which is 5.
The factors of 15 are 3 and 5. For a large N the only slow step is finding r, because the classical steps around it are quick. Shor's insight was that a quantum computer can find r without checking each candidate in turn.
The algorithm does not work by trying every answer at once. The machine holds many inputs together, but a measurement returns only one. The answer emerges because interference cancels the unhelpful outcomes and strengthens the useful ones.
What experiments have shown
In 2001 a team at IBM and Stanford used a seven-qubit nuclear magnetic resonance machine to factor 15, using the same a = 7 as the example above, as reported in Nature. In 2012 a photonic experiment factored 21, using a qubit that was recycled during the run. These were milestones for the field and not threats to any key.
Critics have argued that such demonstrations prove less than they appear to. John Smolin, Graeme Smith and Alex Vargo showed in 2013 that a compiled version, which builds in knowledge of the answer, can appear to factor far larger numbers using almost no quantum resources. A fair test needs an uncompiled circuit with error correction, and that is the machine the fault tolerance tracker follows.
What it would take at full size
Factoring a 2048-bit number needs a very long, very precise calculation. Errors build up in every physical qubit, so the machine needs error correction and many physical qubits per logical one. In 2025 Craig Gidney estimated fewer than a million noisy physical qubits and under a week. The guide to qubits needed to break RSA explains the figure and its assumptions.
The wider consequences are in the Q-Day overview. The change to new encryption is covered in post-quantum cryptography.