Algorithms
Shor's algorithm, explained simply
Shor's algorithm explained in plain English: how a quantum computer factors numbers, why it breaks RSA, an interactive demo, and how many qubits it needs.
On this page
In 30 seconds
- Shor's algorithm (Peter Shor, 1994) lets a quantum computer factor large numbers and solve discrete logarithms exponentially faster than any known classical method.
- That breaks RSA and elliptic-curve cryptography, the public-key systems behind HTTPS, digital signatures and Bitcoin.
- The trick: turn factoring into finding the period of a repeating pattern, which a quantum computer does with interference.
- Running it on real key sizes needs an error-corrected machine: under 1 million noisy qubits for RSA-2048 in a 2025 estimate. Nobody has one yet.
Why factoring matters
RSA encryption rests on a simple bet: multiplying two huge primes is easy, but splitting the result back into those primes is practically impossible. Elliptic-curve cryptography makes a similar bet on a related problem, the discrete logarithm.
In 1994, Peter Shor showed a quantum computer could win both bets. His algorithm runs in polynomial time, so the work grows modestly as keys get longer, instead of exploding.
The idea in four steps
Shor’s insight was that factoring can be rewritten as a question about repeating patterns. Only one step needs a quantum computer.
- Pick a random number a smaller than N, the number you want to factor.
- Find the period r: how many times you multiply by a before the remainder (mod N) cycles back to 1. This is the quantum step.
- Check the period. If r is even and passes one more check, continue. If not, pick a new a.
- Compute the factors with a greatest-common-divisor calculation, which classical computers do instantly.
Try it yourself:
Factor a number the Shor way
Period finding, step by step
1. Number to factor (N)
3. Powers of a, remainder after dividing by N
4. Turn the period into factors
The quantum part: finding the period
For a 2,048-bit number, the period can be astronomically long, so listing powers one by one is hopeless. A quantum computer instead puts a register into a superposition of many exponents at once and computes ax mod N for all of them together.
Then it applies the quantum Fourier transform. Like a prism splitting light into colors, it makes the wrong answers cancel out and the ones related to the period reinforce each other. Measuring gives a value from which r can be worked out. Our guide to superposition and entanglement explains the interference behind this.
How big a machine does it need?
These estimates fell sharply over the past decade as researchers improved the circuits and error correction. They all assume error-corrected logical qubits running billions of operations, far beyond 2026 hardware.
What’s been demonstrated
Experiments have factored small numbers like 15 and 21. Many of these used “compiled” circuits that build in knowledge of the answer, so they test hardware rather than show the algorithm at scale.
What Shor’s algorithm breaks, and what it doesn’t
| Breaks | Doesn’t break |
|---|---|
| RSA (factoring) | AES and other symmetric ciphers |
| Diffie-Hellman key exchange | SHA-256, SHA-3 hash functions |
| Elliptic-curve crypto (ECDSA, EdDSA, ECDH) | ML-KEM, ML-DSA and other post-quantum standards |
That’s why NIST plans to deprecate RSA and elliptic-curve algorithms after 2030 and disallow them after 2035. The replacements are covered in our post-quantum cryptography guide.
FAQ
What does Shor's algorithm do?
It finds the prime factors of a large number, and solves the related discrete logarithm problem, in polynomial time on a quantum computer. The best known classical algorithms take super-polynomial time, which becomes impractical for numbers with hundreds of digits.
Has Shor's algorithm broken RSA?
No. Demonstrations so far have factored tiny numbers such as 15 and 21, often with shortcuts that rely on knowing the answer. Breaking RSA-2048 needs a large error-corrected quantum computer that doesn't exist yet.
How many qubits does Shor's algorithm need?
For RSA-2048, Craig Gidney's 2025 estimate is under 1 million noisy physical qubits running for under a week, assuming 0.1% error rates. For the 256-bit elliptic curve used in Bitcoin, Google's 2026 analysis estimates under 500,000 physical qubits.
Does Shor's algorithm break all encryption?
No. It breaks public-key systems based on factoring and discrete logarithms, like RSA, Diffie-Hellman and elliptic-curve cryptography. It doesn't break symmetric ciphers like AES or hash functions, and post-quantum algorithms such as ML-KEM are designed to resist it.
Who invented Shor's algorithm?
Peter Shor, then at AT&T Bell Labs, presented it in 1994. The full paper appeared on arXiv in 1995 and in the SIAM Journal on Computing in 1997.
Newsletter
Quantum, minus the hype. Once a week.
The week's real quantum news in plain English, with why it matters and links to the sources. Free, no spam, unsubscribe any time.
Sources
We cite primary sources first: papers, standards bodies and the research teams themselves.
- 01Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer (Shor) · arXiv / SIAM J. Computing
- 02How to factor 2048 bit RSA integers with less than a million noisy qubits (Gidney) · arXiv, May 2025
- 03Securing Elliptic Curve Cryptocurrencies against Quantum Vulnerabilities · Google Quantum AI, Mar 2026
- 04Transition to post-quantum cryptography standards (NIST IR 8547) · NIST, Oct 2026
How we checked this page. Written and fact-checked by the quantum365 editorial team against the primary sources above. Company results are labelled as claims. Last reviewed December 4, 2026.
Spotted an error or an outdated fact? Read our editorial policy to see how we correct pages.
Related
Security & crypto
Will quantum computers break encryption?
Which encryption quantum computers will break (RSA, elliptic curves), what survives (AES), the latest qubit estimates, and a quantum-safe checker.
Read guideAlgorithms
Quantum algorithms explained
The quantum algorithms that matter, in plain English: Shor, Grover, simulation, VQE, QAOA and HHL. What each speeds up, by how much, and when it's usable.
Read guideSecurity & crypto
What is Q-Day?
Q-Day is when a quantum computer can break today's public-key encryption. What it means, the latest estimates, official deadlines, and how to prepare.
Read guideSecurity & crypto
Post-quantum cryptography, explained
Post-quantum cryptography explained: NIST's ML-KEM, ML-DSA, SLH-DSA, FN-DSA and HQC standards, who already uses them, and the 2030 and 2035 deadlines.
Read guideHow it works
Logical qubits vs physical qubits
Why '1,000-qubit' headlines mislead: logical vs physical qubits explained, how many you need for real tasks, and a dated comparison by company.
Read guide