Olympiad Number Theory IV: Primitive Roots, Residues & Bounding

Study Sheet

Olympiad Number Theory IV: Primitive Roots, Residues & Bounding

Orders that control exponents, quadratic residues that kill equations, and size arguments that finish them

Orders and Primitive Roots

Concept
The order controls everything

If an≡1(modp)a^n \equiv 1 \pmod p then ordp(a)∣n\text{ord}_p(a) \mid n, and ordp(a)∣p−1\text{ord}_p(a) \mid p - 1. Hence every prime divisor pp of an−1a^n - 1 with p∤ad−1p \nmid a^d - 1 for d<nd < n satisfies p≡1(modn)p \equiv 1 \pmod n. A primitive root gg mod pp makes every nonzero residue a power gkg^k, turning multiplicative questions into questions about exponents mod p−1p - 1.

The olympiad move: from "p∣2n−1p \mid 2^n - 1" deduce "ordp(2)∣n\text{ord}_p(2) \mid n", intersect with "ordp(2)∣p−1\text{ord}_p(2) \mid p - 1", and get ordp(2)∣gcd⁡(n,p−1)\text{ord}_p(2)\mid\gcd(n,p-1); since ordp(2)>1\text{ord}_p(2)>1 for odd pp, nn and p−1p-1 share a prime factor. This single argument shows n∣2n−1n \mid 2^n - 1 only for n=1n = 1: take the least prime p∣np \mid n; then ordp(2)\text{ord}_p(2) divides both nn and p−1p - 1, hence is 11, so p∣1p \mid 1.

Concept
Lifting the exponent

For odd prime p∣a−bp \mid a - b with p∤abp \nmid ab: vp(an−bn)=vp(a−b)+vp(n)v_p(a^n - b^n) = v_p(a - b) + v_p(n). For p=2p = 2 and nn even: v2(an−bn)=v2(a−b)+v2(a+b)+v2(n)−1v_2(a^n - b^n) = v_2(a - b) + v_2(a + b) + v_2(n) - 1.

LTE answers "exactly which power of pp divides an−bna^n - b^n" in one line, replacing pages of induction. It is the tool for exponential Diophantine equations: compare the pp-adic valuation of both sides and the equation collapses to a small inequality in nn.

Example
Squeezing a power of two

Show 2n+12^n + 1 is a power of 33 only for n=1n = 1 and n=3n = 3. Suppose 2n+1=3m2^n + 1 = 3^m with n≥2n \ge 2. Mod 44, 2n+1≡12^n + 1 \equiv 1, and 3m≡(−1)m3^m \equiv (-1)^m, so mm is even. Then 2n=(3m/2−1)(3m/2+1)2^n = (3^{m/2} - 1)(3^{m/2} + 1) is a product of two powers of 22 differing by 22: they must be 22 and 44, so 3m/2=33^{m/2} = 3, m=2m = 2, n=3n = 3. With n=1n = 1: 3=313 = 3^1. No others.

Quadratic Residues and Size Arguments

Concept
Residues that rule out solutions

−1-1 is a square mod pp iff p≡1(mod4)p \equiv 1 \pmod 4; 22 is a square iff p≡±1(mod8)p \equiv \pm1 \pmod 8; −3-3 iff p≡1(mod3)p \equiv 1 \pmod 3. So a prime dividing x2+1x^2 + 1 is 22 or 1 mod 41 \bmod 4; a prime dividing x2+x+1x^2 + x + 1 is 33 or 1 mod 31 \bmod 3. Quadratic reciprocity: for odd primes p,qp, q, (pq)(qp)=(−1)p−12⋅q−12\left(\frac pq\right)\left(\frac qp\right) = (-1)^{\frac{p-1}{2}\cdot\frac{q-1}{2}}.

These facts prove impossibility and produce infinitely-many-primes theorems: infinitely many primes ≡1(mod4)\equiv 1 \pmod 4, because (n!)2+1(n!)^2 + 1 has a prime factor larger than nn and every such factor is 1 mod 41 \bmod 4. In an equation, look for a factor of the form x2+cx^2 + c and ask which primes may divide it.

Concept
Bounding: squeeze between consecutive powers

If m2<N<(m+1)2m^2 < N < (m + 1)^2 then NN is not a square. To show f(n)f(n) is never a perfect square, find mm with m2<f(n)<(m+1)2m^2 < f(n) < (m + 1)^2 for all large nn, then check the small cases by hand.

Size arguments finish what residues start. "n4+2n3+2n2+2n+1n^4 + 2n^3 + 2n^2 + 2n + 1 is a square" — it sits strictly between (n2+n)2(n^2 + n)^2 and (n2+n+1)2(n^2 + n + 1)^2 for every n≥1n \ge 1 (the gaps are n2+2n+1n^2+2n+1 and n2n^2), so no. The same logic for cubes and for "the product of two consecutive integers is never a perfect power". Write the two bounding expressions explicitly and verify the strict inequalities with the actual difference.

Side note
Where it goes wrong

Using LTE without checking p∣a−bp \mid a - b (it is a hypothesis, not a conclusion), and applying the p=2p = 2 case for odd nn.

Try it
Try it: bounding

Show that n2+3n+3n^2 + 3n + 3 is never a perfect square for n≥1n \ge 1.

Show the answer

(n+1)2=n2+2n+1<n2+3n+3<n2+4n+4=(n+2)2(n + 1)^2 = n^2 + 2n + 1 < n^2 + 3n + 3 < n^2 + 4n + 4 = (n + 2)^2 for n≥1n \ge 1 (the right inequality is n+1>0n + 1 > 0). Strictly between consecutive squares.

Primitive Roots in Use

Theorem
Power residues through a primitive root
124836121195107
Powers 2⁰, 2¹, …, 2¹¹ mod 13 in order around the clock; the cubes are every third position (filled).

Let pp be prime and gg a primitive root mod pp. For p∤ap\nmid a and k≥1k\ge1 put e=gcd⁡(k,p−1)e=\gcd(k,p-1). Then xk≡a(modp)x^k\equiv a\pmod p has exactly ee solutions if a(p−1)/e≡1a^{(p-1)/e}\equiv1, and none otherwise; there are p−1e\tfrac{p-1}{e} nonzero kk-th power residues. Also

1m+2m+⋯+(p−1)m≡{−1,(p−1)∣m,0,(p−1)∤m(modp).1^m+2^m+\cdots+(p-1)^m\equiv\begin{cases}-1,&(p-1)\mid m,\\0,&(p-1)\nmid m\end{cases}\pmod p.

Every nonzero residue is a power of gg, and gs≡gs′g^s\equiv g^{s'} exactly when s≡s′(modp−1)s\equiv s'\pmod{p-1}, so multiplication mod pp becomes addition of exponents mod p−1p-1. With x=gsx=g^s and a=gta=g^t, the congruence xk≡ax^k\equiv a becomes the linear congruence ks≡t(modp−1)ks\equiv t\pmod{p-1}, which is solvable exactly when e∣te\mid t, and then has ee solutions mod p−1p-1. The condition e∣te\mid t is the same as a(p−1)/e=gt(p−1)/e≡1a^{(p-1)/e}=g^{t(p-1)/e}\equiv1. For the power sums, as xx runs over the nonzero residues, xm=gsmx^m=g^{sm} and the sum is the geometric series ∑s=0p−2(gm)s\sum_{s=0}^{p-2}(g^m)^s: it is p−1≡−1p-1\equiv-1 if gm≡1g^m\equiv1, i.e. (p−1)∣m(p-1)\mid m, and gm(p−1)−1gm−1≡0\tfrac{g^{m(p-1)}-1}{g^m-1}\equiv0 otherwise. The clock shows the exponent picture for p=13p=13, g=2g=2.

Example
Worked: cube roots mod 13

Which residues mod 1313 are cubes? Solve x3≡5(mod13)x^3\equiv5\pmod{13}. What changes mod 101101? (folklore)

Step 1 — 22 is a primitive root mod 1313: its powers are 1,2,4,8,3,6,12,11,9,5,10,71,2,4,8,3,6,12,11,9,5,10,7, all twelve nonzero residues.

Step 2 — x=2sx=2^s gives x3=23sx^3=2^{3s}, and 3s mod 123s\bmod12 is a multiple of 33, so the nonzero cubes are 20,23,26,29=1,8,12,52^0,2^3,2^6,2^9=1,8,12,5: there are 12gcd⁡(3,12)=4\tfrac{12}{\gcd(3,12)}=4 of them.

Step 3 — 5=295=2^9, so x=2sx=2^s with 3s≡9(mod12)3s\equiv9\pmod{12}, i.e. s≡3(mod4)s\equiv3\pmod4: s=3,7,11s=3,7,11, giving x=8,11,7x=8,11,7. Check: 83=512=39⋅13+58^3=512=39\cdot13+5. Three solutions, as e=gcd⁡(3,12)=3e=\gcd(3,12)=3 predicts.

Step 4 — mod 101101, gcd⁡(3,100)=1\gcd(3,100)=1: cubing is a bijection, so every residue is a cube and each has exactly one cube root.

How to find it. Power questions mod pp are linear questions about exponents mod p−1p-1; the only number that matters is gcd⁡(k,p−1)\gcd(k,p-1).

Example
Worked: a power sum mod 101

Find the remainder of 12026+22026+⋯+10020261^{2026}+2^{2026}+\cdots+100^{2026} modulo 101101.

Step 1 — 101101 is prime and the sum runs over all nonzero residues, so the power-sum formula applies with m=2026m=2026.

Step 2 — p−1=100p-1=100 does not divide 20262026 (2026=20⋅100+262026=20\cdot100+26), so the sum is ≡0\equiv0.

Step 3 — the mechanism, concretely: multiplying every term by g2026g^{2026} for a primitive root gg only permutes the terms (as xx runs over residues so does gxgx), so the sum Σ\Sigma satisfies g2026Σ≡Σg^{2026}\Sigma\equiv\Sigma; and g2026=g26≢1g^{2026}=g^{26}\not\equiv1 because the order of gg is 100100. Hence Σ≡0\Sigma\equiv0. The remainder is 00.

How to find it. A sum over a complete set of nonzero residues is invariant under multiplication by any unit — the "multiply by gg" trick is the whole proof.

Example
Worked: Wolstenholme's theorem

Let p≥5p\ge5 be prime. Prove that the numerator of 1+12+13+⋯+1p−11+\tfrac12+\tfrac13+\cdots+\tfrac1{p-1}, in lowest terms, is divisible by p2p^2. (Wolstenholme, 1862)

Step 1 — pair kk with p−kp-k: 1k+1p−k=pk(p−k)\tfrac1k+\tfrac1{p-k}=\tfrac{p}{k(p-k)}, so 2H=p∑k=1p−11k(p−k)2H=p\sum_{k=1}^{p-1}\tfrac1{k(p-k)}, where HH is the harmonic sum. The denominators are prime to pp, so it suffices to show ∑k=1p−11k(p−k)≡0(modp)\sum_{k=1}^{p-1}\tfrac1{k(p-k)}\equiv0\pmod p, computing with inverses mod pp.

Step 2 — mod pp, k(p−k)≡−k2k(p-k)\equiv-k^2, so the sum is ≡−∑k=1p−1k−2\equiv-\sum_{k=1}^{p-1}k^{-2}.

Step 3 — as kk runs over the nonzero residues so does k−1k^{-1}, so ∑k−2≡∑k2=(p−1)p(2p−1)6\sum k^{-2}\equiv\sum k^2=\tfrac{(p-1)p(2p-1)}{6}, which is divisible by pp because p≥5p\ge5 does not divide 66. (This is the power-sum formula with m=2m=2 and (p−1)∤2(p-1)\nmid2.)

Step 4 — so 2H=p⋅(a fraction whose numerator is divisible by p)2H=p\cdot(\text{a fraction whose numerator is divisible by }p), and since pp is odd, p2p^2 divides the numerator of HH. Check: p=5p=5 gives 2512\tfrac{25}{12} and p=7p=7 gives 4920\tfrac{49}{20}.

How to find it. Harmonic sums mod pp become sums of inverses, which are sums of powers in disguise; pairing kk with p−kp-k extracts the first factor of pp, and the power-sum formula supplies the second.

Side note
Where it goes wrong: no primitive root

Tempting: "x2≡1(mod8)x^2\equiv1\pmod8 has gcd⁡(2,φ(8))=2\gcd(2,\varphi(8))=2 solutions, namely ±1\pm1." In fact 12≡32≡52≡72≡1(mod8)1^2\equiv3^2\equiv5^2\equiv7^2\equiv1\pmod8 — four solutions.

The count gcd⁡(k,φ(n))\gcd(k,\varphi(n)) comes from writing every unit as a power of a primitive root, and there is no primitive root mod 88: every unit has order 11 or 22, so the unit group is not cyclic. Primitive roots exist only mod 1,2,4,pk1,2,4,p^k and 2pk2p^k for odd primes pp. Modulo a composite without one, split with the Chinese remainder theorem and count modulo each prime power separately; mod 2k2^k with k≥3k\ge3 the units form {±1}×⟨5⟩\{\pm1\}\times\langle5\rangle rather than a cycle.

Try it
Try it: fifth powers mod 11

How many solutions does x5≡3(mod11)x^5\equiv3\pmod{11} have? And x5≡10(mod11)x^5\equiv10\pmod{11}? Find the solutions of the second.

Show the answer

Here e=gcd⁡(5,10)=5e=\gcd(5,10)=5, so x5≡ax^5\equiv a is solvable iff a10/5=a2≡1a^{10/5}=a^2\equiv1, i.e. a≡±1a\equiv\pm1. Since 32=9≢13^2=9\not\equiv1, the first has no solutions. For the second, 10≡−110\equiv-1 and (−1)2=1(-1)^2=1, so there are exactly 55 solutions. By Euler's criterion x5≡−1x^5\equiv-1 exactly when xx is a quadratic non-residue mod 1111; the residues are 1,4,9,5,31,4,9,5,3, so the solutions are the non-residues x≡2,6,7,8,10x\equiv2,6,7,8,10.

Quadratic Residues in Diophantine Equations

Tip
Which primes can divide x2+cx^2+c?

If a prime q∤cq\nmid c divides x2+cx^2+c, then −c-c is a quadratic residue mod qq. In particular:

  • every odd prime factor of x2+1x^2+1 is ≡1(mod4)\equiv1\pmod4;
  • every odd prime factor of x2+2x^2+2 is ≡1,3(mod8)\equiv1,3\pmod8, and of x2−2x^2-2 is ≡±1(mod8)\equiv\pm1\pmod8;
  • a positive integer ≡3(mod4)\equiv3\pmod4 has a prime factor ≡3(mod4)\equiv3\pmod4 (a product of primes ≡1(mod4)\equiv1\pmod4 is ≡1\equiv1).

Combining the first and last: x2+1x^2+1 has no divisor d≡3(mod4)d\equiv3\pmod4, d>0d>0.

q∣x2+cq\mid x^2+c means x2≡−c(modq)x^2\equiv-c\pmod q, and q∤xq\nmid x (else q∣cq\mid c), so −c-c is a nonzero square mod qq. The supplements (−1q)=(−1)(q−1)/2\left(\tfrac{-1}q\right)=(-1)^{(q-1)/2} and (±2q)\left(\tfrac{\pm2}q\right) turn that into congruence conditions on qq. The third item is multiplicativity mod 44. The pattern in equations: rearrange so that one side is y2+cy^2+c and the other has a factor ≡3(mod4)\equiv3\pmod4 (or another forbidden class), and the equation is impossible. The main work is finding the factor, since a factor that is ≡3(mod4)\equiv3\pmod4 only for some values of the variable does not suffice.

Example
Worked: 4xy−x−y=z24xy-x-y=z^2

Prove that 4xy−x−y=z24xy-x-y=z^2 has no solution with x,yx,y positive integers and zz an integer. (Euler)

Step 1 — multiply by 44 and add 11: 16xy−4x−4y+1=(4x−1)(4y−1)16xy-4x-4y+1=(4x-1)(4y-1), so the equation becomes (4x−1)(4y−1)=4z2+1=(2z)2+1(4x-1)(4y-1)=4z^2+1=(2z)^2+1.

Step 2 — 4x−1≥34x-1\ge3 and 4x−1≡3(mod4)4x-1\equiv3\pmod4, so it has a prime factor q≡3(mod4)q\equiv3\pmod4.

Step 3 — qq divides (2z)2+1(2z)^2+1, so −1-1 is a quadratic residue mod qq, impossible for q≡3(mod4)q\equiv3\pmod4.

How to find it. Simon's trick in its "multiply by 44" form produces (4x−1)(4y−1)(4x-1)(4y-1), and the right side becomes a square plus one. Once one side is u2+1u^2+1 and the other contains a factor ≡3(mod4)\equiv3\pmod4, the first supplement ends the problem.

Example
Worked: prime factors of 2n+12^n+1 for odd nn

Let nn be odd. Prove that every prime factor of 2n+12^n+1 is ≡1\equiv1 or 3(mod8)3\pmod8. (folklore)

Step 1 — let p∣2n+1p\mid2^n+1; pp is odd. Since nn is odd, 2n=2⋅(2(n−1)/2)22^n=2\cdot\left(2^{(n-1)/2}\right)^2, so 2⋅u2≡−12\cdot u^2\equiv-1 with u=2(n−1)/2u=2^{(n-1)/2}.

Step 2 — multiply by 22: (2u)2≡−2(modp)(2u)^2\equiv-2\pmod p, so −2-2 is a quadratic residue mod pp.

Step 3 — (−2p)=(−1p)(2p)=1\left(\tfrac{-2}p\right)=\left(\tfrac{-1}p\right)\left(\tfrac2p\right)=1 exactly when p≡1p\equiv1 or 3(mod8)3\pmod8 (both factors +1+1 for p≡1p\equiv1, both −1-1 for p≡3p\equiv3). Examples: 29+1=513=33⋅192^9+1=513=3^3\cdot19 and 211+1=2049=3⋅6832^{11}+1=2049=3\cdot683, with 19≡683≡3(mod8)19\equiv683\equiv3\pmod8.

How to find it. An odd power of 22 is twice a square; that single observation converts divisibility into a residue statement about −2-2.

Example
Worked: y2=x3+7y^2=x^3+7

Prove that y2=x3+7y^2=x^3+7 has no integer solutions. (Lebesgue, 1869)

Step 1 — if xx is even, x3+7≡7(mod8)x^3+7\equiv7\pmod8, not a square (squares are 0,1,4 mod 80,1,4\bmod8). So xx is odd.

Step 2 — add 11: y2+1=x3+8=(x+2)(x2−2x+4)y^2+1=x^3+8=(x+2)(x^2-2x+4).

Step 3 — x2−2x+4=(x−1)2+3x^2-2x+4=(x-1)^2+3. With xx odd, (x−1)2≡0(mod4)(x-1)^2\equiv0\pmod4, so this factor is ≡3(mod4)\equiv3\pmod4, and it is positive. It therefore has a prime factor q≡3(mod4)q\equiv3\pmod4.

Step 4 — qq divides y2+1y^2+1, impossible by the first supplement. No solutions.

How to find it. 7=8−17=8-1: adding 11 to both sides makes the left a sum of two squares and the right a sum of two cubes, which factors. Then look for the factor whose residue mod 44 is forced for every odd xx.

Side note
Where it goes wrong: a factor that is only sometimes 3 mod 43\bmod4

In y2+1=(x+2)(x2−2x+4)y^2+1=(x+2)(x^2-2x+4), tempting: "xx is odd, so x+2x+2 is odd; it is ≡3(mod4)\equiv3\pmod4 and has a prime factor ≡3(mod4)\equiv3\pmod4."

x+2≡3(mod4)x+2\equiv3\pmod4 only when x≡1(mod4)x\equiv1\pmod4. For x=3x=3, x+2=5x+2=5, and 55 can perfectly well divide y2+1y^2+1 (take y=2y=2). The argument has proved nothing for half of the odd xx. The factor to use is the one whose residue is forced for every odd xx: (x−1)2+3≡3(mod4)(x-1)^2+3\equiv3\pmod4. Check the claimed congruence on a sample value from each residue class before building on it.

Try it
Try it: fifth powers meet squares

Prove that x2=y5−4x^2=y^5-4 has no integer solutions. (Balkan MO 1998)

Show the answer

Work mod 1111, where fifth powers are very restricted: for 11∤y11\nmid y, (y5)2=y10≡1\left(y^5\right)^2=y^{10}\equiv1, so y5≡±1y^5\equiv\pm1; hence y5∈{0,1,10}(mod11)y^5\in\{0,1,10\}\pmod{11} and y5−4∈{7,8,6}y^5-4\in\{7,8,6\}. The squares mod 1111 are 0,1,4,9,5,30,1,4,9,5,3, which contain none of 6,7,86,7,8. So no integers satisfy the equation.