Shor's Factoring Complexity
Time complexity for Shor's algorithm to factor an integer N on a quantum computer.
Formula
Variables
Example
RSA-2048: classical ≈ 10³⁰ ops; Shor's ≈ 10⁹ ops
How it works
This complexity says that, on an ideal quantum computer, the main runtime for factoring an integer N grows with the cube of the number of bits needed to write N, because log N is the input size and Shor’s algorithm uses repeated modular exponentiation plus a quantum Fourier transform. The key reason it is so much faster than classical factoring methods is that the quantum part can extract the period of a modular function in polynomial time, instead of searching through candidates. In practice, the O((log N)^3) form is an asymptotic estimate for the core algorithm, not the full engineering cost of error correction and hardware overhead.
When to use it
Use this when estimating the theoretical runtime of Shor’s algorithm for integer factoring in quantum computing or computational complexity. It is especially relevant in cryptography, where you compare quantum factoring cost against the security of RSA-style keys.
Worked example, step by step
Factor a 1024-bit integer. log2(N) = 1024 Shor’s algorithm complexity scales as O((log N)^3) So the relative work is about 1024^3 1024^3 = 1,073,741,824 Final result: the core factoring effort scales like about 1.07 × 10^9 basic time units, up to constant factors and lower-order terms.
Common mistakes to avoid
- Using N itself instead of log N as the input size
- Treating O((log N)^3) as the exact runtime rather than an asymptotic scaling
- Ignoring that real quantum computers need extra overhead for error correction and fault-tolerant gates
Did You Know?
Shor's algorithm is the reason the world is racing to develop post-quantum cryptography before large-scale quantum computers arrive.
Share this formula
More in Quantum Computing
View allQubit Superposition State
IntermediateGeneral state of a single qubit as a superposition of the computational basis states.
Normalisation Constraint
BasicThe squared amplitudes of a qubit must sum to 1, ensuring total probability is 100 %.
Hadamard Gate
IntermediatePuts a qubit into an equal superposition — the most common single-qubit gate.
Pauli-X Gate (Quantum NOT)
BasicFlips |0⟩ to |1⟩ and vice versa — the quantum equivalent of a classical NOT gate.
CNOT Gate
IntermediateTwo-qubit gate that flips the target qubit only when the control qubit is |1⟩.
Bell State (EPR Pair)
IntermediateMaximally entangled two-qubit state — measuring one qubit instantly determines the other.