This repository contains implementations of Shor's algorithm for integer factorization using both quantum and classical approaches. The algorithm demonstrates the potential of quantum computing to solve certain problems exponentially faster than classical computers.
Shor's algorithm is a quantum algorithm for integer factorization. Given an integer N, it finds its prime factors. The algorithm consists of two parts:
- A reduction, which can be done on a classical computer, of the factoring problem to the problem of order-finding.
- A quantum algorithm to solve the order-finding problem.
This repository contains several implementations:
-
Python Implementations:
shor_2_0.py: A comprehensive implementation with quantum state simulationshors.py: A simpler implementation focusing on the classical parts491_final.py: Implementation using Qiskit for IBM quantum computersmain.py: Main script to run the algorithmlargeCircuits.py: Utility for generating quantum circuits
-
C++ Implementations:
shor.C: Main implementationqureg.C: Quantum register implementationcomplex.C: Complex number operationsutil.C: Utility functions
numpy>=1.20.0
qiskit>=0.30.0
matplotlib>=3.4.0
scipy>=1.7.0
- Standard C++ compiler
- Math library
# Run the main implementation
python main.py
# Run the Qiskit implementation
python 491_final.py# Compile the C++ implementation
g++ -o shor shor.C qureg.C complex.C util.C -lm
# Run the compiled program
./shorThis project is licensed under the terms included in the LICENSE file.
- Shor, P. W. (1999). Polynomial-Time Algorithms for Prime Factorization and Discrete Logarithms on a Quantum Computer. SIAM Review, 41(2), 303-332.
- Nielsen, M. A., & Chuang, I. L. (2010). Quantum Computation and Quantum Information. Cambridge University Press.