KnowledgeCookies logo Understanding the language of quantum science
QPicDepict / Quantum computing

Shor factoring

Shor’s algorithm uses a quantum routine to find a modular period, then extracts factors by classical arithmetic.

Shor factoring infographic. A reading guide and explanation follow.
Period finding for a=2a = 2, N=15N = 15. Exponent x, 0, 1, 2, 3, 4, 5. 2x2^{x} mod 15, 1, 2, 4, 8, 1, 2. Open full-size image Download PNG

How it works

  1. Choose

    Pick a with gcd⁡(a,N)=1\gcd(a,N)=1, or use a nontrivial gcd immediately.

  2. Estimate the order

    Quantum phase estimation on modular multiplication gives samples close to rational values with denominator r. Continued fractions and checks recover a candidate order.

  3. Extract

    For even r with a^(r/2) not congruent to −1 modulo N, try gcd(a^(r/2) ± 1,N).

Equation and quantities

r=ord⁡N(a)r=\operatorname{ord}_N(a)

Worked example

Here r=4r = 4, so ar/2=4a^{r/2}=4. The gcd of 3 with 15 is 3 and the gcd of 5 with 15 is 5.

Why it matters

Efficient ideal-circuit factoring motivates migration away from cryptosystems that rely on factoring hardness.

Limits and assumptions

Some bases and samples give unusable results, so the procedure can require retries. Practical large-instance factoring requires fault-tolerant resources.

Why does 24≡1(mod15)2^4\equiv1\pmod{15} help?

It makes (222^{2} − 1)(222^{2} + 1) a multiple of 15, exposing factors through gcds.

Related reading