Skip to main content

Shor’s Algorithm on Dynex

Shor’s algorithm factorizes integers exponentially faster than the best known classical algorithm. It reduces factorization to period finding using the quantum Fourier transform.

How it works

  1. Quantum state preparation — superposition via Hadamard gates on estimate qubits; target qubit initialized to |1⟩ via Pauli-X
  2. Controlled unitaries — powers of modular exponentiation unitary U_NA (from integers a and N) applied to target qubits, controlled by estimate qubits
  3. Inverse QFT — extracts phase information related to the period r of f(x) = a^x mod N
  4. Measurement — samples encode period information
  5. Post-processing — continued fractions + GCD to extract prime factors from period r

Example: Factorize N=35

Full notebook

circuit_example_shor.ipynb