A small number.
A quantum way in.
Factor 15 with seven simulated qubits. Watch interference reveal a hidden period, then turn that period into the two factors.
3 counting + 4 target
01 / The quantum circuit
EXACT · NO NOISETarget starts in |0001⟩. Three controlled modular multiplications entangle the registers; the inverse QFT makes the period visible.
Counting-register probabilities
|AMPLITUDE|²02 / Unlocking the factors
CLASSICAL POSTPROCESSINGPreparing the quantum measurement distribution.
03 / Measurement notebook
24 independent circuit measurements. Zero outcomes and trivial roots stay in the record.
| Shot | Measured | Phase / fraction | Period check | gcd(x − 1, 15) / gcd(x + 1, 15) | Outcome |
|---|
Controlled multiplication is a permutation unitary: |y⟩ → |a·y mod 15⟩ for y < 15; |15⟩ stays fixed. We simulate its action directly instead of decomposing arithmetic into elementary gates. Superposition, interference and measurement all use the actual statevector.
This is a noiseless, seven-qubit educational simulation for N = 15 only. Shor’s algorithm threatens RSA at a vastly larger, fault-tolerant scale. This demo cannot factor real RSA keys. Try a = 14 to see an honest failure: an even period can still give a trivial root.