Quantum Computing
Advanced

Shor's Factoring Complexity

Time complexity for Shor's algorithm to factor an integer N on a quantum computer.

Formula

O((log⁡N)3)O((\log N)^3)

Variables

NInteger to factorise

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

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026