This repository contains a Qiskit implementation of the period-finding oracle (
In this notebook, we build a quantum period-finding oracle for Shor's algorithm, with demonstrations and verifications of each component part, primarily following the
Google Gemini was particularly useful for testing the functions, debugging, and referencing syntax. In particular, we used it to explain and verify the binary arithmetic that is crucial for the algorithm.
Shor's algorithm makes use of the harmonic analytic properties of arithmetic, namely periodicity, to find a factor for a positive integer
This quantum oracle is made up of the following composite parts, each built and verified in schoracle.ipynb:
- An adder (
phi_add), similar to the Draper adder, with addition achieved via phase change in the Fourier basis. - A QFT-based modular adder (
phi_add_mod) built from the above. - A controlled modular multiplier (
c_mult_mod), built from successive applications of the modular adder. - The final oracle
$U_a$ (c_U), which uses the modular multiplier and controlled swaps to perform the desired computation.
This project requires Python 3 and the following Python libraries:
- Qiskit
- NumPy
- Matplotlib
The main implementation and verification for the oracle are contained within the schoracle.ipynb Jupyter Notebook.
[Bea03] Beauregard, S. (2003), Circuit for Shor's algorithm using 2n+3 qubits, arXiv:quant-ph/0205095.
[Nag25] Nagy, A. (2025), Course Notes: Erdos Institute Fall 2025 Quantum Computing Bootcamp
[NC10] Nielsen, M. A., & Chuang, I. L. (2010), Quantum Computation and Quantum Information: 10th Anniversary Edition, Cambridge University Press.
[Qis25] Qiskit contributors (2025), Learn Quantum Computation using Qiskit, https://qiskit.org/learn
[Sho97] Shor, P. W. (1997). Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer, SIAM Journal on Computing, 26(5), 1484-1509.