Skip to main content
KetQat

Appearance

Theorem · intermediate

Factoring reduces to order finding

For an odd N with at least two distinct prime factors, a uniformly random a coprime to N has even order r with a^(r/2) not congruent to -1 with probability at least 1/2; then gcd(a^(r/2) - 1, N) is a nontrivial factor. Hence an order-finding routine factors N in randomized polynomial time.

Established resultMachine-checkedUpdated 2026-12-01 · last verified 2026-12-01

AI-assisted text, machine-checked, not yet reviewed by a person. Citations resolve and an automated pass compared the statements with the cited sources. That is not peer review; check the sources for anything you depend on.

Under the assumptions,

Pr⁡[ r is even and ar/2≢−1(modN) ]  ≥  1−12m−1  ≥  12.\Pr\big[\, r \text{ is even and } a^{r/2} \not\equiv -1 \pmod N \,\big] \;\ge\; 1 - \frac{1}{2^{m-1}} \;\ge\; \frac12 .

Whenever this event occurs, b=ar/2 mod Nb = a^{r/2} \bmod N is a square root of 1 modulo NN other than ±1\pm 1, and both gcd⁡(b−1,N)\gcd(b - 1, N) and gcd⁡(b+1,N)\gcd(b + 1, N) are nontrivial factors of NN.

The remaining cases are classical: if NN is even, 2 is a factor; if N=pαN = p^{\alpha} with α≥2\alpha \ge 2, this is detected by computing integer kk-th roots for k≤log⁡2Nk \le \log_2 N; and if a random aa has gcd⁡(a,N)>1\gcd(a, N) > 1, that gcd is a factor. So any procedure that returns the order of a given aa yields a randomized polynomial-time factoring algorithm with expected O(1)O(1) calls. This reduction, standard in number theory and used by Shor, is Theorem 5.3 of Nielsen and Chuang. The book prints the bound with exponent mm; the exponent m−1m-1 is what the argument gives and is the version in the book's errata list. It is tight: for N=21N = 21 exactly half of Z21∗\Z_{21}^\ast succeeds.

Holds when

  • N=p1α1⋯pmαmN = p_1^{\alpha_1}\cdots p_m^{\alpha_m} is odd with m≥2m \ge 2 distinct prime factors.
  • aa is drawn uniformly from the multiplicative group ZN∗\Z_N^\ast of residues coprime to NN; rr is its order, the least r≥1r \ge 1 with ar≡1(modN)a^r \equiv 1 \pmod N.

Proof

Proof that factoring reduces to order findingMachine-checked

Two standard facts from elementary number theory are used (Appendix 4 of Nielsen and Chuang): the Chinese remainder theorem, by which a↦(a mod p1α1,…,a mod pmαm)a \mapsto (a \bmod p_1^{\alpha_1}, \dots, a \bmod p_m^{\alpha_m}) is a group isomorphism ZN∗≅Zp1α1∗×⋯×Zpmαm∗\Z_N^\ast \cong \Z_{p_1^{\alpha_1}}^\ast \times \cdots \times \Z_{p_m^{\alpha_m}}^\ast; and the fact that for an odd prime pp the group Zpα∗\Z_{p^\alpha}^\ast is cyclic, of order φ(pα)=pα−1(p−1)\varphi(p^\alpha) = p^{\alpha-1}(p-1).

The gcd step. Suppose rr is even and b=ar/2≢−1b = a^{r/2} \not\equiv -1. Also b≢1b \not\equiv 1, since r/2<rr/2 < r and rr is the least exponent with ar≡1a^r \equiv 1. Then N∣b2−1=(b−1)(b+1)N \mid b^2 - 1 = (b-1)(b+1) while N∤b−1N \nmid b - 1 and N∤b+1N \nmid b + 1. So NN shares a factor with b−1b - 1 but is not contained in it: 1<gcd⁡(b−1,N)<N1 < \gcd(b-1, N) < N, and likewise for b+1b + 1.

Failure forces equal valuations. Let rjr_j be the order of aa modulo pjαjp_j^{\alpha_j}, so that r=lcm⁡(r1,…,rm)r = \operatorname{lcm}(r_1, \dots, r_m), and let djd_j be the exponent of the largest power of 2 dividing rjr_j; let dd be that of rr, so d=max⁡jdjd = \max_j d_j. The procedure fails when rr is odd or ar/2≡−1a^{r/2} \equiv -1.

  • If rr is odd, every rjr_j is odd and d1=⋯=dm=0d_1 = \dots = d_m = 0.
  • If rr is even and ar/2≡−1(modN)a^{r/2} \equiv -1 \pmod N, then ar/2≡−1≢1a^{r/2} \equiv -1 \not\equiv 1 modulo each pjαjp_j^{\alpha_j} (as pjp_j is odd), so rj∤r/2r_j \nmid r/2. Since rj∣rr_j \mid r, this means rjr_j contains the full power 2d2^{d}, i.e. dj=dd_j = d for every jj.

In both cases all djd_j are equal.

Each valuation is spread out. By the Chinese remainder theorem, aa uniform on ZN∗\Z_N^\ast means that the components aj=a mod pjαja_j = a \bmod p_j^{\alpha_j} are independent and uniform on Zpjαj∗\Z_{p_j^{\alpha_j}}^\ast, and djd_j depends only on aja_j. Fix jj, let gg be a generator of the cyclic group Zpjαj∗\Z_{p_j^{\alpha_j}}^\ast of order φj\varphi_j, and let 2D2^{D} be the largest power of 2 dividing φj\varphi_j; D≥1D \ge 1 because pj−1p_j - 1 is even. The element gkg^{k} has order φj/gcd⁡(k,φj)\varphi_j/\gcd(k, \varphi_j), whose 2-adic exponent is DD when kk is odd and less than DD when kk is even. As kk ranges uniformly over {0,…,φj−1}\{0, \dots, \varphi_j - 1\} exactly half the values are odd, so Pr⁡[dj=D]=1/2\Pr[d_j = D] = 1/2 and consequently Pr⁡[dj=c]≤1/2\Pr[d_j = c] \le 1/2 for every value cc.

Conclusion. Conditioning on a1a_1 and using independence,

Pr⁡[failure]≤Pr⁡[d2=d1,…,dm=d1]=Ea1[∏j=2mPr⁡[dj=d1∣a1]]≤12m−1.\Pr[\text{failure}] \le \Pr[d_2 = d_1, \dots, d_m = d_1] = \mathbb{E}_{a_1}\Big[\prod_{j=2}^{m}\Pr[d_j = d_1 \mid a_1]\Big] \le \frac{1}{2^{m-1}} .

For m≥2m \ge 2 this is at most 1/21/2. The structure of the argument follows the proof of Theorem 5.3 in Nielsen and Chuang; counting the conditioning on d1d_1 explicitly gives the exponent m−1m - 1.

Part of

Open in the knowledge graph

Contributions about this record

Nobody has published a contribution about it yet.

Publish a result, reproduction or commentPropose a correction to this page

References

  1. Peter W. Shor (1997). Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM Journal on Computing 26(5), 1484-1509. doi:10.1137/S0097539795293172arXiv:quant-ph/9508027
  2. Michael A. Nielsen, Isaac L. Chuang (2010). Quantum Computation and Quantum Information (10th Anniversary Edition). Cambridge University Press. doi:10.1017/CBO9780511976667

Contributors

  • KetQat maintainers · @ketqatConceptualization; Supervision (CRediT roles)
  • Claude (AI drafting assistant)Writing, original draft (CRediT roles)

Review history

  1. Automated source check · Pass with notes · 2026-12-01 · Independent automated verification pass (AI, not the drafting session)

    Bound 1 - 1/2^(m-1) and the gcd step re-derived (see proof/factoring-reduces-to-order-finding) and checked exhaustively for every odd N < 1200 with at least two distinct prime factors (no violation, minimum 1/2 at N = 21; every successful a gave nontrivial gcd(b-1,N) and gcd(b+1,N)). The correction of the textbook exponent m to m-1 compared with Willsch et al., arXiv:2308.05047, Appendix (eq. A26 and remark citing Nielsen's errata list and Ekert-Jozsa). The theorem number 5.3 in Nielsen-Chuang matches a web-search summary of Nielsen's errata list (errata page itself returned 404); the book's theorem text was not opened.

    The record hinted that the exponent m-1 differs from the book only in a parenthesis. Nielsen-Chuang prints 1 - 1/2^m, which is wrong (errata corrects it to m-1). Made this explicit and added that the bound is tight at N = 21 (checked numerically).

Revision history

  1. 2026-12-01Content release 2.1.0: 35 more topics, an independent source check of every record, intake hardening (#17)80537b7e
  2. 2026-11-30KetQat Commons: free learning paths, knowledge records, research problems, literature intake (#14)571c9b10

Current revision 2c59d122545ef425. Source file knowledge/records/theorem/factoring-reduces-to-order-finding.md in the content repository (readable there once it is public).