Number Theory

Study Sheet

Number Theory

Orders, valuations, quadratic residues, Diophantine equations, divisor sums

Proof-Level Number Theory

Tip
Orders, primitive roots, and CRT

The order of aa mod nn divides every kk with ak≡1a^k \equiv 1, hence divides φ(n)\varphi(n). Compute orders mod composites prime-power by prime-power and take the lcm.

Last two digits of 320263^{2026}: the order of 33 mod 100100 is 2020, and 2026≡62026 \equiv 6, so 36=729→293^6 = 729 \to 29. Mod 2k2^k (k≥3k \ge 3) the equation x2≡1x^2 \equiv 1 has FOUR solutions, so x2≡1(mod24)x^2 \equiv 1 \pmod{24} has 4⋅2=84\cdot2 = 8 — a standard trap. Primitive roots exist exactly mod 2,4,pk,2pk2, 4, p^k, 2p^k.

Tip
Valuations: Legendre, Kummer, LTE

vp(n!)=∑k≥1⌊n/pk⌋v_p(n!) = \sum_{k\ge1}\lfloor n/p^k\rfloor; vp(nk)v_p\binom{n}{k} is the number of carries adding k+(n−k)k + (n-k) in base pp; vp(an−bn)=vp(a−b)+vp(n)v_p(a^n - b^n) = v_p(a - b) + v_p(n) for odd p∣a−bp \mid a - b.

v5(1000!)=200+40+8+1=249v_5(1000!) = 200 + 40 + 8 + 1 = 249. v2(20261013)v_2\binom{2026}{1013} is the number of 11-bits of 10131013. LTE: v3(2243+1)=1+5=6v_3(2^{243} + 1) = 1 + 5 = 6 (the an+bna^n + b^n form for odd nn). Valuations turn "largest power dividing" into arithmetic, and they are the language of most Putnam number theory write-ups.

Tip
Divisor sums and multiplicative functions

τ\tau, σ\sigma, φ\varphi are multiplicative: compute on prime powers and multiply. σ(360)=15⋅13⋅6=1170\sigma(360) = 15\cdot13\cdot6 = 1170; ∑d∣nφ(d)=n\sum_{d\mid n}\varphi(d) = n.

Sums over divisors are attacked by swapping the order of summation: ∑n≤Nτ(n)=∑d≤N⌊N/d⌋\sum_{n\le N}\tau(n) = \sum_{d\le N}\lfloor N/d\rfloor. Möbius inversion recovers ff from F(n)=∑d∣nf(d)F(n) = \sum_{d\mid n}f(d). Quadratic residues: (−1p)=(−1)(p−1)/2\left(\tfrac{-1}{p}\right) = (-1)^{(p-1)/2}, (2p)=1\left(\tfrac{2}{p}\right) = 1 iff p≡±1(mod8)p \equiv \pm1 \pmod 8, and reciprocity for the rest.

Side note
Diophantine reflexes

Factor (SFFT: xy+ax+by=cxy + ax + by = c becomes (x+b)(y+a)=c+ab(x + b)(y + a) = c + ab); bound (compare growth rates, squeeze between consecutive squares); take mod a small number (squares are 0,1 mod 40, 1 \bmod 4, cubes 0,±1 mod 90, \pm1 \bmod 9); descend (Vieta jumping, infinite descent). Nearly every Putnam Diophantine problem yields to one of these four, and knowing which to try first is a matter of pattern practice.

Reminder — Vieta's formulas:  r1+r2=−ba,r1r2=car_1+r_2=-\frac{b}{a},\qquad r_1 r_2=\frac{c}{a}
Side note
Where it goes wrong

"φ(100)=40\varphi(100) = 40, so exponents can be reduced mod 4040: 241≡21=2(mod100)2^{41} \equiv 2^1 = 2 \pmod{100}." In fact 241=2199023255552≡522^{41} = 2199023255552 \equiv 52. Euler's theorem aφ(n)≡1a^{\varphi(n)} \equiv 1 needs gcd⁡(a,n)=1\gcd(a, n) = 1, and gcd⁡(2,100)=2\gcd(2, 100) = 2. Split by CRT instead: mod 44, 241≡02^{41} \equiv 0; mod 2525, gcd⁡(2,25)=1\gcd(2, 25) = 1 and the order of 22 divides 2020, so 241≡21=22^{41} \equiv 2^1 = 2. The number ≡0(mod4)\equiv 0 \pmod 4 and ≡2(mod25)\equiv 2 \pmod{25} is 5252.

Try it
Try it: a valuation

Find the largest kk such that 2k2^k divides (10050)\binom{100}{50}.

Show the answer

Kummer: count carries adding 50+5050 + 50 in base 22. 50=110010250 = 110010_2; doubling a binary number produces one carry per 11-bit, and 5050 has three 11-bits: k=3k = 3. (Legendre confirms: v2(100!)−2v2(50!)=97−2⋅47=3v_2(100!) - 2v_2(50!) = 97 - 2\cdot47 = 3.)

Proofs & Why It Matters

Tip
Proof: lifting the exponent (odd prime case)

For odd prime pp with p∣a−bp \mid a - b and 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).

Two lemmas. (i) If p∤np \nmid n then vp(an−bn)=vp(a−b)v_p(a^n - b^n) = v_p(a - b): since an−bn=(a−b)∑an−1−ibia^n - b^n = (a - b)\sum a^{n-1-i}b^i and the sum is ≡nan−1≢0(modp)\equiv na^{n-1} \not\equiv 0 \pmod p. (ii) vp(ap−bp)=vp(a−b)+1v_p(a^p - b^p) = v_p(a - b) + 1: write a=b+kpta = b + kp^t and expand apa^p binomially — the terms beyond the first two carry extra factors of pp, and the (p2)\binom p2 term supplies exactly one more (this is where pp odd is used). Induct on vp(n)v_p(n), peeling off one factor of pp at a time with (ii) and finishing with (i). ■\blacksquare Significance: LTE is the exact accounting of how a prime divides a difference of powers — it replaces pages of casework in olympiad and Putnam solutions alike.

Tip
Proof: ∑d∣nφ(d)=n\sum_{d\mid n}\varphi(d) = n

A one-line counting proof of a multiplicative identity.

Sort the fractions 1n,2n,…,nn\tfrac1n, \tfrac2n, \ldots, \tfrac nn by their reduced denominator dd (a divisor of nn). Exactly φ(d)\varphi(d) of them reduce to denominator dd (the numerators coprime to dd). Summing over dd counts all nn fractions. ■\blacksquare Significance: the argument proves more — that the multiplicative group mod pp is cyclic (count elements by order, compare with ∑φ(d)=p−1\sum\varphi(d) = p - 1), i.e. primitive roots exist.

Going Deeper: Worked Problems

Example
Worked: an order computation via CRT

Find the order of 33 modulo 10001000.

Step 1 — 1000=8⋅1251000 = 8\cdot125; the order mod 10001000 is the lcm of the orders mod 88 and mod 125125.

Step 2 — mod 88: 32=9≡13^2 = 9 \equiv 1, order 22.

Step 3 — mod 125125: φ(125)=100\varphi(125) = 100, so the order divides 100100; test the maximal proper divisors 5050 and 2020. 320≡1+20⋅…3^{20} \equiv 1 + 20\cdot\ldots — compute: 35=243≡−73^5 = 243 \equiv -7, 310≡493^{10} \equiv 49, 320≡492=2401≡26≠13^{20} \equiv 49^2 = 2401 \equiv 26 \ne 1; 350=(310)5≡4953^{50} = (3^{10})^5 \equiv 49^5, and 492≡2649^2 \equiv 26, 494≡262=676≡5149^4 \equiv 26^2 = 676 \equiv 51, 495≡51⋅49=2499≡−1≠149^5 \equiv 51\cdot49 = 2499 \equiv -1 \ne 1. So the order mod 125125 is 100100.

Step 4 — lcm(2,100)=100\mathrm{lcm}(2, 100) = 100. The method: never search; use φ\varphi to list candidates and test only the maximal proper divisors.

Example
Worked: a Diophantine equation by bounding
49n = 19916n = 2151625n = 3232536n = 4333649n = 5454964n = 659
Each row runs from (n + 1)² to (n + 2)²; the dot is n² + 3n + 5. Only for n = 1 does it reach the square at the right end (9); for n ≥ 2 it falls strictly between.

Find all positive integers nn such that n2+3n+5n^2 + 3n + 5 is a perfect square.

Step 1 — squeeze between consecutive squares: for n≥1n \ge 1, (n+1)2=n2+2n+1<n2+3n+5(n + 1)^2 = n^2 + 2n + 1 < n^2 + 3n + 5 and (n+2)2=n2+4n+4>n2+3n+5(n + 2)^2 = n^2 + 4n + 4 > n^2 + 3n + 5 iff n>1n > 1.

Step 2 — so for n≥2n \ge 2 the expression lies strictly between two consecutive squares: never a square.

Step 3 — check n=1n = 1: 1+3+5=9=321 + 3 + 5 = 9 = 3^2 ✓. Answer: only n=1n = 1. Bounding by neighboring squares (or cubes) is the first thing to try on "when is this polynomial a perfect power."

Example
Worked: the power of 2 in 31024−13^{1024} - 1 (folklore)

Find the largest kk such that 2k2^k divides 31024−13^{1024} - 1.

Step 1 — 1024=2101024 = 2^{10}, and differences of squares factor repeatedly: 32m−1=(32m−1−1)(32m−1+1)3^{2^{m}} - 1 = \left(3^{2^{m-1}} - 1\right)\left(3^{2^{m-1}} + 1\right). Unwinding, 31024−1=(3−1)(3+1)(32+1)(34+1)⋯(3512+1)3^{1024} - 1 = (3 - 1)(3 + 1)(3^2 + 1)(3^4 + 1)\cdots(3^{512} + 1).

Step 2 — the 22-adic valuations: 3−1=23 - 1 = 2 contributes 11, and 3+1=43 + 1 = 4 contributes 22. For j≥1j \ge 1, 32j3^{2^j} is an odd square, hence ≡1(mod8)\equiv 1 \pmod 8, so 32j+1≡2(mod8)3^{2^j} + 1 \equiv 2 \pmod 8 contributes exactly 11; there are nine such factors (j=1,…,9j = 1, \ldots, 9).

Step 3 — total: 1+2+9=121 + 2 + 9 = 12. So k=12k = 12. In general v2(32m−1)=m+2v_2\left(3^{2^m} - 1\right) = m + 2, the p=2p = 2 case of lifting the exponent: v2(xn−yn)=v2(x−y)+v2(x+y)+v2(n)−1v_2(x^n - y^n) = v_2(x - y) + v_2(x + y) + v_2(n) - 1 for odd x,yx, y and even nn.

How to find it. An exponent that is a power of 22 invites repeated difference-of-squares factoring; then each factor's power of 22 is read off mod 88. The odd-prime LTE formula from the Proofs section fails at p=2p = 2 — this is the corrected version, with the extra v2(x+y)−1v_2(x + y) - 1.