Reduction to Period Finding
Shor's algorithm does not directly decompose a large integer. Instead it transforms the factoring problem into a completely different one — period finding — and then solves that with the quantum Fourier transform. This lesson traces that transformation step by step.
Why period finding breaks factoring
Let be the integer you want to factor, and pick any with and (a is coprime to ). Consider the sequence
Because there are only possible remainders, this sequence must eventually repeat. The smallest positive integer such that
is called the order (or period) of modulo . It always exists when .
From the period to a factor
Once you know , a single algebraic identity yields a factor with high probability.
Step 1. If is odd, or if , the argument fails — restart with a different . Both bad cases happen with probability at most for any composite that is not a prime power, so on average two random choices of suffice.
Step 2. If is even and , write the identity
and factor the left side as a difference of squares:
Since neither factor is (by assumption), the product is divisible by but neither factor alone is. That means shares a non-trivial common factor with at least one of and .
Step 3. Compute and . At least one of these is a proper factor of .
Worked example: factoring 15
Choose , . The period is (even, and ).
Compute .
Both GCDs are proper factors, confirming .
The only remaining difficulty is computing efficiently. Classically, evaluating for all up to takes time exponential in the bit-length of . The quantum speedup comes entirely from the next step: using the quantum Fourier transform to read off the period from a superposition of all powers at once.
The full reduction in one sentence
Shor's algorithm replaces the classically hard question "what are the prime factors of ?" with the quantumly easy question "what is the order of modulo ?", then extracts factors from the order using three lines of classical arithmetic.
Sign in on the full site to ask questions and join the discussion.