Maths WorkshopMaths problems with full solutions
Exercise 2191Number theory › PrimesM1Added 3 Nov 2026

The AKS primality test (statement)

#AKS#deterministic primality#polynomial time

Statement

State the AKS primality test and its significance.

Hint

The AKS test checks (X+a)n≡Xn+a(modXr−1,n)(X+a)^n\equiv X^n+a\pmod{X^r-1,n} for certain r,ar,a.

Show solutionHide solution

Solution

Setup. Given nn, find small rr such that ord⁡r(n)>log⁡2n\operatorname{ord}_r(n)>\log^2 n, and check that gcd⁡(a,n)=1\gcd(a,n)=1 for all a≤ra\le r.

Test. For each a≤⌊φ(r)log⁡n⌋a\le\lfloor\sqrt{\varphi(r)}\log n\rfloor, check
(X+a)n≡Xn+a(modXr−1,n).(X+a)^n\equiv X^n+a\pmod{X^r-1,n}.
If all hold, nn is prime; otherwise composite.

Significance. First deterministic polynomial-time primality test (Agrawal–Kayal–Saxena, 2002). Complexity O(log⁡6+ϵn)O(\log^{6+\epsilon}n).

Conclusion. AKS proved that primality testing is in P.