How Shor’s Algorithm Factors 314191
Source: How Shor’s Algorithm Factors 314191, minutephysics, 5:52, uploaded 2019-05-22, playlist index 334.
MinutePhysics follows up its explanation of quantum computers and encryption with a small, complete factoring example. The story is a bank vault full of pies whose access code uses the composite number . The number is small enough for the video to name the intermediate quantum states, although the method is meant to explain why factoring large RSA numbers could threaten public-key encryption. The description calls 314191 a pseudoprime and links the example to the number-theoretic form of Shor’s algorithm.
From factoring to order-finding
Shor’s algorithm does not search through possible factors one by one. It starts with a random number and checks whether already shares a factor with . If it does, the classical calculation is finished. If it does not, the useful question becomes the smallest positive power for which
This is the period, or order, of modulo . When the period is even, the expression gives a route to two factors through the greatest common divisors of with and . The video calls a much better guess because each value can share a non-trivial factor with .
The classical part is easy to state. Finding for a large is the hard part, and that is where the quantum computation enters.
The first period: 101
The video chooses . Euclid’s algorithm shows that 101 shares no factor with 314191, so the example proceeds to order-finding.
The imagined quantum computer raises 101 to many powers at once and records the remainders modulo 314191. A superposition of possible exponents becomes a superposition of values such as , , , and their remainders. Measuring the remainder might return 74126. The remaining state then contains the exponents that produced that remainder.
For this small example, the video can calculate those exponents explicitly. They include 20, 4367, and 8714. Their spacing is 4347, so the hidden period is . In a real factoring problem, the computer would leave the exponents in a periodic state without handing us a neat list of them. The periodic spacing is the information that matters.
The next step makes that spacing visible as a frequency. A quantum Fourier transform turns a state with period into a superposition of multiples of . The video first gives the simplified picture of , then adds the qualification it skipped in the earlier explanation: technical details make the transform produce , , , and so on. For the example, those frequencies are multiples of .
Measurement returns one value at random. One run might give , another , and another . Repeating the computation lets the common denominator emerge, which reveals . The source keeps the classical reconstruction brief because the small example lets it name the answer directly.
The result checks out: is one more than a multiple of 314191. The multiple is enormous, even though the number being factored is small enough for the animation to keep visible.
An odd period forces a restart
The first run reaches a genuine failure. The period 4347 is odd, so is not a whole number. The factoring step cannot use , and the video drops the calculation with an audible “oh, crap” before starting again with .
The second run repeats the same order-finding process. This time it finds
so . The two Euclidean-algorithm calculations are now useful:
and
The factors multiply back to the original number:
The bank-vault code is open and the pies are available. The demonstration earns its conclusion through the failed first choice as much as through the successful second one. The quantum part finds a period, while the final factor extraction remains a familiar Euclidean calculation.
What the small example leaves out
The video calls its first account a rough overview and uses the second video to fill in one detail about the Fourier transform. Its numbers are deliberately small, which lets the creator show the remainders, exponent gaps, frequency samples, and final greatest common divisors. A cryptographic instance would hide those values inside a far larger state. The note therefore records the source’s teaching example rather than treating it as a demonstration of a practical quantum machine breaking a current RSA key.
The captions and description do not explain the circuit that performs modular exponentiation, the number of qubits, error correction, success probabilities, or the classical method that reconstructs a period from measured Fourier samples. They also attach the encryption claim to the motivating context rather than proving a security result. The durable part of the example is the division of labour: quantum interference exposes the period in modular arithmetic, and ordinary number theory turns that period into factors.
Further reading / references
The video description lists these references and related material. They belong to the source’s bibliography; this note does not independently verify their arguments.
- RSA numbers, a collection of sample large integers to factor.
- Modulo Multiplication Group Tables, difference-of-squares factorisation, and Euclid’s algorithm.
- Scott Aaronson’s blog post about Shor’s algorithm and his quantum computing course notes.
- An experimental implementation of Shor’s algorithm, factoring 15, 21, and 35.
- Adiabatic quantum computation factoring 291311.
- Shor’s algorithm on Quantiki.
- The description also links IBM’s RSA overview, rational sieving, the general number field sieve, and TLS as related context.