Mathematics · Book 3 · Bachelor Year 1

University Mathematics — Year 1

University Mathematics — Year 1 · Bachelor Year 1

6Integer Arithmetic

Arithmetic — the study of divisibility in Z\Z — was begun in the High School volume. This chapter rebuilds it completely from the Euclidean division, with full proofs: greatest common divisor and the Euclidean algorithm, Bézout’s identity and Gauss’s lemma, prime factorization, and the calculus of congruences up to Fermat’s little theorem. Beyond its own charm, this material is the model that Chapter 8 imitates for polynomials.

6.1 Divisibility and Euclidean division

Definition 6.1 (Divisibility)

For a,bZa, b \in \Z, bb divides aa (written bab \mid a) when a=bqa = bq for some qZq \in \Z. Basic consequences: if bab \mid a and bab \mid a' then b(ua+va)b \mid (ua + va') for all u,vZu, v \in \Z; if bab \mid a and a0a \neq 0 then ba\abs b \leq \abs a; and aba \mid b together with bab \mid a force b=±ab = \pm a.

Theorem 6.2 (Euclidean division)

For all aZa \in \Z and bNb \in \N^*, there is exactly one pair (q,r)Z×N(q, r) \in \Z \times \N with

a=bq+r,0r<b.a = bq + r, \qquad 0 \leq r < b .

Proof. Existence. The set A={abk:kZ}NA = \{a - bk : k \in \Z\} \cap \N is a nonempty subset of N\N (take k=ak = -\abs a: a+baa+a0a + b\abs a \geq a + \abs a \geq 0). Let r=abqr = a - bq be its least element. If rbr \geq b, then rb=ab(q+1)r - b = a - b(q+1) would be a smaller element of AA: contradiction. So 0r<b0 \leq r < b.

Uniqueness. If bq+r=bq+rbq + r = bq' + r' with 0r,r<b0 \leq r, r' < b, then b(qq)=rrb(q - q') = r' - r and rr<b\abs{r' - r} < b: the multiple of bb in the left-hand side must be 00, so q=qq = q' and r=rr = r'.

Example 6.3 (Positional numeration by repeated division)

Write 20262026 in base 77. Divide repeatedly by 77, keeping the remainders:

2026=7×289+3,289=7×41+2,41=7×5+6,5=7×0+5.2026 = 7 \times 289 + 3, \quad 289 = 7 \times 41 + 2, \quad 41 = 7 \times 5 + 6, \quad 5 = 7 \times 0 + 5 .

Reading the remainders from last to first: 2026=(5623)72026 = (5\,6\,2\,3)_7. Check: 5×343+6×49+2×7+3=1715+294+14+3=20265 \times 343 + 6 \times 49 + 2 \times 7 + 3 = 1715 + 294 + 14 + 3 = 2026. The uniqueness of Euclidean division is exactly what makes each digit forced: at every step the remainder is the only integer in [ ⁣[0,6] ⁣]\intint06 congruent to the current value mod 77, so base-77 writing is unique — the fact silently used whenever the weekend problem manipulates “the digits of nn in base pp”.

6.2 Greatest common divisor

Theorem 6.4 (Subgroups of Z\Z; existence of the gcd)

  1. Every subgroup of (Z,+)(\Z, +) is of the form nZ={nk:kZ}n\Z = \{nk : k \in \Z\} for a unique nNn \in \N.
  2. For a,bZa, b \in \Z not both zero, the set aZ+bZ={au+bv:u,vZ}a\Z + b\Z = \{au + bv : u, v \in \Z\} is a subgroup of Z\Z, hence equals dZd\,\Z for a unique dNd \in \N^*. This dd is the greatest common divisor gcd(a,b)\gcd(a, b): it divides aa and bb, and every common divisor of aa and bb divides dd.

Proof. (1) Let HZH \subseteq \Z be a subgroup (nonempty, stable under subtraction; the formal definition is in Chapter 7, and only these two properties are used). If H={0}H = \{0\}, take n=0n = 0. Otherwise HH contains a nonzero element and its opposite, hence a smallest strictly positive element nn. Then nZHn\Z \subseteq H. For xHx \in H, write x=nq+rx = nq + r with 0r<n0 \leq r < n (Theorem 6.2); r=xnqHr = x - nq \in H, and minimality of nn forces r=0r = 0: xnZx \in n\Z. Uniqueness: nn is the least positive element of nZn\Z.

(2) aZ+bZa\Z + b\Z contains 00 and is stable under subtraction, so it is dZd\Z with d1d \geq 1 (it contains aa or bb nonzero). Since a,bdZa, b \in d\Z, dd divides both. And if cc divides aa and bb, then cc divides every au+bvau + bv — in particular cdc \mid d, since daZ+bZd \in a\Z + b\Z. This is the property announced (and it implies cd\abs c \leq d, so dd deserves the name greatest common divisor).

Corollary 6.5 (Bézout’s identity)

For a,ba, b not both zero, there exist u,vZu, v \in \Z with

au+bv=gcd(a,b).au + bv = \gcd(a, b) .

In particular (gcd(a,b)=1\gcd(a,b) = 1, the coprime case): aa and bb are coprime if and only if au+bv=1au + bv = 1 has a solution.

Proof. gcd(a,b)=ddZ=aZ+bZ\gcd(a,b) = d \in d\Z = a\Z + b\Z. For the equivalence: if gcd(a,b)=1\gcd(a,b) = 1, Bézout provides the solution; conversely au+bv=1au + bv = 1 forces every common divisor of a,ba, b to divide 11.

Method 6.6 (Euclidean algorithm, extended)

To compute gcd(a,b)\gcd(a, b) (a>b>0a > b > 0): divide a=bq+ra = bq + r; then gcd(a,b)=gcd(b,r)\gcd(a, b) = \gcd(b, r) (common divisors of (a,b)(a,b) and of (b,r)(b,r) coincide, since r=abqr = a - bq); iterate until the remainder is 00; the last nonzero remainder is the gcd. Running the divisions backwards (or maintaining the coefficients on the way down) produces a Bézout pair (u,v)(u, v).

Example 6.7

gcd(120,23)\gcd(120, 23): 120=5×23+5120 = 5 \times 23 + 5; 23=4×5+323 = 4 \times 5 + 3; 5=1×3+25 = 1\times 3 + 2; 3=1×2+13 = 1 \times 2 + 1; 2=2×1+02 = 2 \times 1 + 0. So gcd=1\gcd = 1. Backwards:

1=32=3(53)=2×35=2(234×5)5=2×239×5=2×239(1205×23)=47×239×120.\begin{align*} 1 &= 3 - 2 = 3 - (5 - 3) = 2\times 3 - 5 = 2(23 - 4\times 5) - 5 \\ &= 2 \times 23 - 9 \times 5 = 2\times 23 - 9(120 - 5\times 23) = 47 \times 23 - 9 \times 120 . \end{align*}

Check: 47×23=108147 \times 23 = 1081, 9×120=10809 \times 120 = 1080.

Theorem 6.8 (Gauss’s lemma and consequences)

Let a,b,cZa, b, c \in \Z.

  1. (Gauss’s lemma) If abca \mid bc and gcd(a,b)=1\gcd(a, b) = 1, then aca \mid c.
  2. If aca \mid c, bcb \mid c and gcd(a,b)=1\gcd(a,b) = 1, then abcab \mid c.
  3. If gcd(a,b)=gcd(a,c)=1\gcd(a, b) = \gcd(a, c) = 1, then gcd(a,bc)=1\gcd(a, bc) = 1.

Proof. (1) Bézout: au+bv=1au + bv = 1. Multiply by cc: acu+bcv=cacu + bcv = c. Both terms are divisible by aa (the second because abca \mid bc), so aca \mid c.

(2) Write c=aqc = aq; from baqb \mid aq and gcd(a,b)=1\gcd(a, b) = 1, point (1) gives bqb \mid q, so abaq=cab \mid aq = c.

(3) au+bv=1au + bv = 1 and au+cv=1au' + cv' = 1. Multiply the two relations:

1=(au+bv)(au+cv)=a(auu+ucv+ubv)+bc(vv),1 = (au + bv)(au' + cv') = a\,\bigl(auu' + ucv' + u'bv\bigr) + bc\,(vv') ,

a Bézout relation between aa and bcbc: by Corollary 6.5, gcd(a,bc)=1\gcd(a, bc) = 1.

Example 6.9 (Solving a linear Diophantine equation)

Find all (x,y)Z2(x, y) \in \Z^2 with 6x+10y=46x + 10y = 4. First, the existence test: gcd(6,10)=2\gcd(6, 10) = 2 divides 44, so solutions exist (if the gcd did not divide the right-hand side, the left side would always be a multiple of it and there would be none). Divide through: 3x+5y=23x + 5y = 2. A particular solution is visible: (x0,y0)=(1,1)(x_0, y_0) = (-1, 1). For the general one, subtract: 3(x+1)=5(y1)3(x + 1) = -5(y - 1), so 35(y1)3 \mid 5(y-1), and Gauss’s lemma (gcd(3,5)=1\gcd(3,5) = 1) gives 3y13 \mid y - 1: y=13ky = 1 - 3k, then x=1+5kx = -1 + 5k. Conversely every such pair works:

(x,y)=(1+5k, 13k),kZ.(x, y) = (-1 + 5k,\ 1 - 3k), \qquad k \in \Z .

The pattern is general: one particular solution plus the integer multiples of (bgcd,agcd)\bigl(\frac b{\gcd}, -\frac a{\gcd}\bigr) — the same “particular plus homogeneous” structure as in Chapter 5, with Gauss’s lemma playing the uniqueness role.

Definition 6.10 (Least common multiple)

lcm(a,b)\operatorname{lcm}(a, b) is the generator in N\N of the subgroup aZbZa\Z \cap b\Z: it is a common multiple of aa and bb that divides every common multiple, and for a,bNa, b \in \N^*,

gcd(a,b)×lcm(a,b)=ab(proof in Exercise 6.5).\gcd(a,b) \times \operatorname{lcm}(a,b) = ab \qquad (\text{proof in } \text{Exercise 6.5}).

Example 6.11 (Alignment problems are lcm problems)

Two meshed gears have 8484 and 3636 teeth. After how many teeth of common motion do they return to their initial position together? The configuration repeats when the number of elapsed teeth is a common multiple of 8484 and 3636; the first time is

lcm(84,36)=84×36gcd(84,36)=302412=252\operatorname{lcm}(84, 36) = \frac{84 \times 36}{\gcd(84, 36)} = \frac{3024}{12} = 252

teeth — that is, 33 turns of the large gear and 77 of the small one (252/84252/84 and 252/36252/36). Note the practical route: compute the gcd first (Euclid: 84=2×36+1284 = 2\times36 + 12, 36=3×1236 = 3\times12), then divide — never build the lcm by listing multiples. Every periodic-coincidence question (gears, planetary alignments, repeating decimals meeting) reduces to this one computation.

6.3 Prime numbers

Definition 6.12

An integer p2p \geq 2 is prime when its only positive divisors are 11 and pp. For pp prime and aZa \in \Z: either pap \mid a, or gcd(p,a)=1\gcd(p, a) = 1. Consequently (Theorem 6.8), Euclid’s lemma holds: if pabp \mid ab then pap \mid a or pbp \mid b.

Remark 6.13 (Testing primality by trial division)

If n=abn = ab with 2ab2 \leq a \leq b, then a2ab=na^2 \leq ab = n, so ana \leq \sqrt n: a composite nn always has a prime divisor n\leq \sqrt n. Hence to test whether nn is prime it suffices to try the primes up to n\sqrt n. For n=271n = 271: 271<17\sqrt{271} < 17, and 271271 is divisible by none of 2,3,5,7,11,132, 3, 5, 7, 11, 13 (odd, digit sum 1010, does not end in 00 or 55, 271=738+5=1124+7=1320+11271 = 7\cdot38 + 5 = 11\cdot24 + 7 = 13\cdot20 + 11): prime, after six divisions instead of two hundred. The n\sqrt n barrier is a genuine threshold: crossing it efficiently for hundred-digit numbers requires the modern primality tests grown out of Theorem 6.23.

Theorem 6.14 (Euclid)

There are infinitely many primes.

Proof. Every integer n2n \geq 2 has a prime divisor: its smallest divisor 2\geq 2 is prime (a proper factorization of it would produce a smaller divisor of nn). Now suppose p1,,pkp_1, \dots, p_k were all the primes, and let N=p1p2pk+12N = p_1 p_2 \cdots p_k + 1 \geq 2. Some prime pip_i divides NN; but pip_i also divides N1=p1pkN - 1 = p_1\cdots p_k, so pi1p_i \mid 1 — absurd.

Theorem 6.15 (Fundamental theorem of arithmetic)

Every integer n2n \geq 2 is a product of primes, and the factorization

n=p1α1p2α2pkαk(p1<p2<<pk primes, αiN)n = p_1^{\alpha_1} p_2^{\alpha_2} \cdots p_k^{\alpha_k} \qquad (p_1 < p_2 < \dots < p_k \text{ primes},\ \alpha_i \in \N^*)

is unique.

Proof. Existence by strong induction (Theorem 1.12): n=2n = 2 is prime; for n>2n > 2, either nn is prime, or n=abn = ab with 2a,b<n2 \leq a, b < n, and the induction hypothesis factors aa and bb.

Uniqueness. Suppose p1pr=q1qsp_1 \cdots p_r = q_1 \cdots q_s (primes listed with repetition, rsr \leq s say), and induct on rr. If r=0r = 0 the left side is 11, forcing s=0s = 0 (a nonempty product of primes exceeds 11). For r1r \geq 1: the prime p1p_1 divides q1(q2qs)q_1(q_2\cdots q_s), so by Euclid’s lemma either p1q1p_1 \mid q_1 or p1q2qsp_1 \mid q_2\cdots q_s; iterating, p1p_1 divides some qjq_j. But qjq_j is prime and p12p_1 \geq 2: necessarily p1=qjp_1 = q_j. Cancel this common factor (legitimate: Z\Z is an integral domain) to get

p2pr=q1qj^qsp_2 \cdots p_r = q_1 \cdots \widehat{q_j} \cdots q_s

(the hat marking omission), an equality of shorter products; the induction hypothesis says the two lists p2,,prp_2, \dots, p_r and q1,,qj^,,qsq_1, \dots, \widehat{q_j}, \dots, q_s coincide up to order, hence so did the original ones. The exponent form groups equal primes.

Proposition 6.16 (Valuations)

For pp prime and nNn \in \N^*, write vp(n)v_p(n) for the exponent of pp in the factorization of nn (with vp(n)=0v_p(n) = 0 if pnp \nmid n). Then

vp(mn)=vp(m)+vp(n),mn    p, vp(m)vp(n),v_p(mn) = v_p(m) + v_p(n), \qquad m \mid n \iff \forall p,\ v_p(m) \leq v_p(n),
vp(gcd(m,n))=min(vp(m),vp(n)),vp(lcm(m,n))=max(vp(m),vp(n)).v_p\bigl(\gcd(m,n)\bigr) = \min\bigl(v_p(m), v_p(n)\bigr), \qquad v_p\bigl(\operatorname{lcm}(m,n)\bigr) = \max\bigl(v_p(m), v_p(n)\bigr).

Proof. The first identity holds because the factorizations multiply and the factorization of mnmn is unique. If mnm \mid n, write n=mqn = mq and apply it. Conversely, if all vp(m)vp(n)v_p(m) \leq v_p(n), the integer q=ppvp(n)vp(m)q = \prod_p p^{\,v_p(n) - v_p(m)} satisfies mq=nmq = n. The gcd formula: the integer d=pmind = \prod p^{\min} divides both by the criterion, and every common divisor cc has vp(c)minv_p(c) \leq \min for all pp, so cdc \mid d; same reasoning for the lcm with max\max.

Example 6.17 (Squares and cubes through valuations)

An integer n1n \geq 1 is a perfect square if and only if every vp(n)v_p(n) is even (if n=m2n = m^2, then vp(n)=2vp(m)v_p(n) = 2v_p(m); conversely halve every exponent). Likewise for cubes with multiples of 33. Thus 21168=24×33×7221168 = 2^4 \times 3^3 \times 7^2 is not a square (v3=3v_3 = 3 is odd) and not a cube (v2=4v_2 = 4); the smallest positive integer mm such that 21168m21168\,m is a cube is found by topping up each exponent to the next multiple of 33:

m=264×333×732=22×7=28,21168×28=263373=(22×3×7)3=843.m = 2^{6-4} \times 3^{3-3} \times 7^{3-2} = 2^2 \times 7 = 28, \qquad 21168 \times 28 = 2^6\,3^3\,7^3 = (2^2 \times 3 \times 7)^3 = 84^3 .

The insight: multiplicative questions (squares, cubes, divisors, gcd, lcm) become coordinatewise questions on the exponent vectors (v2,v3,v5,)(v_2, v_3, v_5, \dots) — unique factorization is the statement that these coordinates exist and are well defined.

6.4 Congruences

Definition 6.18

For nNn \in \N^*: ab(modn)a \equiv b \pmod n when nabn \mid a - b. This is an equivalence relation compatible with addition and multiplication: if aba \equiv b and aba' \equiv b' (mod nn), then a+ab+ba + a' \equiv b + b', aabbaa' \equiv bb', and akbka^k \equiv b^k for kNk \in \N.

Example 6.19 (Casting out nines)

Compatibility with ++ and ×\times is a checking device as old as commerce. Since 101(mod9)10 \equiv 1 \pmod 9, every integer is congruent mod 99 to its digit sum (proved as Exercise 6.2). To check the claim 1234×567=6996781234 \times 567 = 699\,678: digit sums give 123411234 \equiv 1 and 567180(mod9)567 \equiv 18 \equiv 0 \pmod 9, so the product must be 1×0=0\equiv 1 \times 0 = 0; and indeed 6+9+9+6+7+8=4506 + 9 + 9 + 6 + 7 + 8 = 45 \equiv 0. The check passes (and the product is in fact correct). Had someone reported 699478699\,478, the digit sum 437≢043 \equiv 7 \not\equiv 0 would convict them instantly. The test is one-sided — it catches an error unless the error is itself a multiple of 99 — which is exactly the pseudoprime lesson of Example 6.24 in miniature: congruence checks refute, they do not certify.

Proposition 6.20 (Invertibility mod nn)

aa is invertible mod nn (i.e. ab1(modn)ab \equiv 1 \pmod n for some bb) if and only if gcd(a,n)=1\gcd(a, n) = 1. The inverse is then unique mod nn and computed by the extended Euclidean algorithm.

Proof. ab1(modn)ab \equiv 1 \pmod n means ab+nk=1ab + nk = 1 for some kk: a Bézout relation, which exists iff gcd(a,n)=1\gcd(a,n) = 1 (Corollary 6.5). Uniqueness: if abab1ab \equiv ab' \equiv 1, then bb(ab)=(ab)bb(modn)b \equiv b(ab') = (ab)b' \equiv b' \pmod n.

Example 6.21 (Inverting 77 modulo 2626)

Since gcd(7,26)=1\gcd(7, 26) = 1, the class of 77 is invertible mod 2626. Extended Euclid:

26=3×7+5,7=1×5+2,5=2×2+1,26 = 3 \times 7 + 5, \qquad 7 = 1 \times 5 + 2, \qquad 5 = 2 \times 2 + 1 ,

then backwards:

1=52×2=52(75)=3×52×7=3(263×7)2×7=3×2611×7.1 = 5 - 2 \times 2 = 5 - 2(7 - 5) = 3 \times 5 - 2 \times 7 = 3(26 - 3 \times 7) - 2 \times 7 = 3 \times 26 - 11 \times 7 .

Hence 7×(11)1(mod26)7 \times (-11) \equiv 1 \pmod{26}, i.e. 711115(mod26)7^{-1} \equiv -11 \equiv 15 \pmod{26}; check: 7×15=105=4×26+17 \times 15 = 105 = 4 \times 26 + 1. With the inverse in hand, any congruence 7xc(mod26)7x \equiv c \pmod{26} is solved in one multiplication: x15cx \equiv 15c. This mechanical inversion is the workhorse of modular arithmetic — and of the public-key protocols mentioned in Remark 6.27, where the moduli have hundreds of digits but the algorithm is exactly this one.

Example 6.22 (When the coefficient is not invertible)

Solve 12x8(mod20)12x \equiv 8 \pmod{20}. Here gcd(12,20)=4\gcd(12, 20) = 4, so 1212 is not invertible mod 2020 — but the equation is still tractable. The congruence says 2012x820 \mid 12x - 8; dividing the whole relation by 44 (divisor of all three ingredients), it is equivalent to 53x25 \mid 3x - 2, i.e.

3x2(mod5).3x \equiv 2 \pmod 5 .

Now gcd(3,5)=1\gcd(3, 5) = 1 and 312(mod5)3^{-1} \equiv 2 \pmod 5 (3×2=613 \times 2 = 6 \equiv 1), so x4(mod5)x \equiv 4 \pmod 5: the solutions are x4,9,14,19(mod20)x \equiv 4, 9, 14, 19 \pmod{20}four classes mod 2020, matching the gcd. (Had the right side not been divisible by 44, say 12x6(mod20)12x \equiv 6 \pmod{20}, there would be no solution at all: the left side is always 0(mod4)\equiv 0 \pmod 4.) General shape: axb(modn)ax \equiv b \pmod n is solvable iff gcd(a,n)b\gcd(a, n) \mid b, and then has exactly gcd(a,n)\gcd(a, n) solution classes — divide everything by the gcd and invert.

Theorem 6.23 (Fermat’s little theorem)

Let pp be prime. For every aZa \in \Z:

apa(modp),a^p \equiv a \pmod p,

and if pap \nmid a, then ap11(modp)a^{p-1} \equiv 1 \pmod p.

Proof. First, for 1kp11 \leq k \leq p - 1, the binomial coefficient (pk)=p!k!(pk)!\binom pk = \frac{p!}{k!(p-k)!} is divisible by pp: indeed k!(pk)!(pk)=p!k!\,(p-k)!\, \binom pk = p! and pp divides p!p! but is coprime to k!(pk)!k!(p-k)! (all factors are <p< p), so Gauss’s lemma gives p(pk)p \mid \binom pk.

Now prove apaa^p \equiv a for aNa \in \N by induction. True for a=0a = 0. If apaa^p \equiv a, then by the binomial theorem

(a+1)p=k=0p(pk)akap+1a+1(modp),(a+1)^p = \sum_{k=0}^{p} \binom pk a^k \equiv a^p + 1 \equiv a + 1 \pmod p,

all middle terms vanishing mod pp. For a<0a < 0, apply the result to a-a and separate p=2p = 2 (where xxx \equiv -x) from odd pp (where (a)p=ap(-a)^p = -a^p). Finally, if pap \nmid a, multiply apaa^p \equiv a by an inverse of aa mod pp (Proposition 6.20).

Example 6.24 (Fermat’s converse fails: 341341)

Fermat’s little theorem gives a cheap compositeness test: if an1≢1(modn)a^{n-1} \not\equiv 1 \pmod n for some aa coprime to nn, then nn is not prime. Could the test also certify primality? No: take n=341=11×31n = 341 = 11 \times 31, composite, and a=2a = 2. Since 210=1024=3×341+12^{10} = 1024 = 3 \times 341 + 1,

2101(mod341)2340=(210)341(mod341):2^{10} \equiv 1 \pmod{341} \qquad\Longrightarrow\qquad 2^{340} = \bigl(2^{10}\bigr)^{34} \equiv 1 \pmod{341} :

the composite 341341 passes Fermat’s test for the base 22 (it is the smallest such pseudoprime). The base 33 unmasks it (3340≢13^{340} \not\equiv 1), and practical primality testing therefore runs the test on several bases, plus refinements — the industrial versions of this idea are what certify the large primes of Remark 6.27. Moral: an implication and its converse live separate lives (Remark 1.10), even for theorems.

Example 6.25 (Practical congruence computations)

What is the remainder of 720267^{2026} mod 1111? By Fermat, 7101(mod11)7^{10} \equiv 1 \pmod{11}. Since 2026=10×202+62026 = 10 \times 202 + 6:

7202676=(72)3=49353=1254(mod11).7^{2026} \equiv 7^6 = (7^2)^3 = 49^3 \equiv 5^3 = 125 \equiv 4 \pmod{11}.

The remainder is 44. The strategy: reduce the exponent modulo the order provided by Fermat, then reduce intermediate powers at every step.

Remark 6.26 (Common pitfalls in arithmetic)

  1. Dividing a congruence. From acbc(modn)ac \equiv bc \pmod n one may not conclude aba \equiv b unless gcd(c,n)=1\gcd(c, n) = 1: 62(mod4)6 \equiv 2 \pmod 4 but 3≢1(mod4)3 \not\equiv 1 \pmod 4. The correct general rule divides the modulus too: acbc(modn)    ab(modn/gcd(c,n))ac \equiv bc \pmod n \iff a \equiv b \pmod{n/\gcd(c,n)}.
  2. Misusing Euclid’s lemma. abca \mid bc implies aba \mid b or aca \mid c only for aa prime (or coprime to one factor): 64×96 \mid 4 \times 9 yet 66 divides neither factor.
  3. Coprime is a relation, not a property.88 and 99 are coprime” is true though neither is prime; “pairwise coprime” is stronger than “globally coprime” (gcd(6,10,15)=1\gcd(6, 10, 15) = 1 but no pair is coprime).
  4. Exponents do not live mod nn. In akmodna^k \bmod n, the exponent may only be reduced modulo the order of aa (for instance p1p - 1 when Fermat applies), never modulo nn: 210mod112^{10} \bmod 11 is 11, not 210mod11=2102^{10 \bmod 11} = 2^{10} — the reduction that works is the one Example 6.25 performs.

Remark 6.27 (Where this chapter is used)

This chapter is a template as much as a toolbox. The whole chain — Euclidean division, gcd, Bézout, Gauss, unique factorization — is replayed verbatim for polynomials in Chapter 8, where “degree” plays the role of absolute value; comparing the two chapters side by side is the best way to understand both. The congruence calculus becomes the ring Z/nZ\Z/n\Z in Chapter 7, whose invertible elements (Proposition 6.20) form the first nontrivial example of a group of units. Valuations return in the weekend problem below (Legendre’s formula) and power the irrationality proofs of Chapter 10. Beyond this volume, Bézout inversion mod nn is the engine of public-key cryptography, and Fermat’s little theorem is the grandfather of the primality tests that certify the large primes used there.

Remark 6.28 (Interlude: Z\Z as a template)

Step back from the individual theorems and observe the architecture of the chapter: one tool (Euclidean division) produced a classification (subgroups nZn\Z), which produced an existence theorem (gcd, Bézout), which produced a divisibility calculus (Gauss), which produced unique factorization — each floor resting only on the one below. The same building will be erected twice more in this volume with different ground floors: in Chapter 8, where division by degree replaces division by size and everything above repeats verbatim; and, in miniature, inside every Z/nZ\Z/n\Z of Chapter 7, where invertibility questions (this chapter’s Proposition 6.20) become structural statements about rings and fields. Recognizing an argument as “the Z\Z-argument, transplanted” is the fastest way to learn those chapters — and the first taste of algebra’s core habit, proving theorems about axioms rather than about objects.

Rows 0 to 7 of Pascal’s triangle with the odd entries filled: row n contains 2s_2(n) of them, where s_2(n) is the number of ones in the binary writing of n (rows 1, 2, 4: two odd entries; row 7 = (111)_2: all eight). The self-similar pattern — each “triangle of odds” spawns two copies of itself — is Kummer’s theorem in picture form, proved in the weekend problem below.
Rows 00 to 77 of Pascal’s triangle with the odd entries filled: row nn contains 2s2(n)2^{s_2(n)} of them, where s2(n)s_2(n) is the number of ones in the binary writing of nn (rows 1,2,41, 2, 4: two odd entries; row 7=(111)27 = (111)_2: all eight). The self-similar pattern — each “triangle of odds” spawns two copies of itself — is Kummer’s theorem in picture form, proved in the weekend problem below.

6.5 Exercises

Exercise 6.1

Compute gcd(1001,777)\gcd(1\,001, 777) by the Euclidean algorithm, and a Bézout pair for it.

Solution

Solution of Exercise 6.1.

1001=1×777+2241001 = 1 \times 777 + 224; 777=3×224+105777 = 3 \times 224 + 105; 224=2×105+14224 = 2 \times 105 + 14; 105=7×14+7105 = 7 \times 14 + 7; 14=2×7+014 = 2 \times 7 + 0. So gcd(1001,777)=7\gcd(1001, 777) = 7. Backwards:

7=1057×14=1057(2242×105)=15×1057×2247 = 105 - 7 \times 14 = 105 - 7(224 - 2\times 105) = 15 \times 105 - 7 \times 224
=15(7773×224)7×224=15×77752×224=15×77752(1001777)=67×77752×1001.= 15(777 - 3\times 224) - 7\times 224 = 15 \times 777 - 52 \times 224 = 15 \times 777 - 52(1001 - 777) = 67 \times 777 - 52 \times 1001 .

Check: 67×777=5205967 \times 777 = 52\,059 and 52×1001=5205252 \times 1001 = 52\,052; difference 77. Bézout pair: (u,v)=(52,67)(u, v) = (-52, 67) for 1001u+777v=71001u + 777v = 7.

Exercise 6.2

Prove the divisibility rules in base 1010: an integer is congruent mod 99 to the sum of its digits, and mod 1111 to the alternating sum of its digits. What is 123456789123\,456\,789 mod 99 and mod 1111?

Solution

Solution of Exercise 6.2.

Since 101(mod9)10 \equiv 1 \pmod 9: 10k110^k \equiv 1, so kdk10kkdk(mod9)\sum_k d_k 10^k \equiv \sum_k d_k \pmod 9. Since 101(mod11)10 \equiv -1 \pmod{11}: 10k(1)k10^k \equiv (-1)^k, so the integer is congruent to the alternating sum k(1)kdk\sum_k (-1)^k d_k mod 1111 (starting from the units digit with sign ++).

123456789123\,456\,789: digit sum 450(mod9)45 \equiv 0 \pmod 9. Alternating sum from the units: 98+76+54+32+1=59 - 8 + 7 - 6 + 5 - 4 + 3 - 2 + 1 = 5, so the number is 5(mod11)\equiv 5 \pmod{11}.

Exercise 6.3

Solve in Z\Z: 91x1(mod237)91x \equiv 1 \pmod{237} (extended Euclid).

Solution

Solution of Exercise 6.3.

Euclid: 237=2×91+55237 = 2 \times 91 + 55; 91=1×55+3691 = 1 \times 55 + 36; 55=1×36+1955 = 1 \times 36 + 19; 36=1×19+1736 = 1 \times 19 + 17; 19=1×17+219 = 1 \times 17 + 2; 17=8×2+117 = 8 \times 2 + 1. Backwards:

1=178×2=178(1917)=9×178×19=9(3619)8×19=9×3617×191 = 17 - 8\times 2 = 17 - 8(19 - 17) = 9\times 17 - 8\times 19 = 9(36 - 19) - 8\times 19 = 9\times 36 - 17\times 19
=9×3617(5536)=26×3617×55=26(9155)17×55=26×9143×55= 9\times 36 - 17(55 - 36) = 26\times 36 - 17\times 55 = 26(91 - 55) - 17\times 55 = 26\times 91 - 43\times 55
=26×9143(2372×91)=112×9143×237.= 26\times 91 - 43(237 - 2\times 91) = 112 \times 91 - 43 \times 237.

So 91×1121(mod237)91 \times 112 \equiv 1 \pmod{237}: the solutions are x112(mod237)x \equiv 112 \pmod{237}. (Check: 91×112=10192=43×237+191 \times 112 = 10\,192 = 43 \times 237 + 1.)

Exercise 6.4

Find all pairs (x,y)Z2(x, y) \in \Z^2 with 17x+39y=117x + 39y = 1; then all pairs with 17x+39y=517 x + 39 y = 5.

Solution

Solution of Exercise 6.4.

gcd(17,39)=1\gcd(17, 39) = 1: Euclid gives 39=2×17+539 = 2\times 17 + 5, 17=3×5+217 = 3\times 5 + 2, 5=2×2+15 = 2\times 2 + 1, and backwards

1=52×2=52(173×5)=7×52×17=7(392×17)2×17=7×3916×17.1 = 5 - 2\times 2 = 5 - 2(17 - 3\times 5) = 7\times 5 - 2\times 17 = 7(39 - 2\times 17) - 2\times 17 = 7\times 39 - 16\times 17 .

Particular solution (x0,y0)=(16,7)(x_0, y_0) = (-16, 7). General solution of the homogeneous equation 17x+39y=017x + 39y = 0: x=39kx = 39k, y=17ky = -17k (since 1739y17 \mid 39y and gcd(17,39)=1\gcd(17,39) = 1 force 17y17 \mid y — Gauss’s lemma). Hence

(x,y)=(16+39k,  717k),kZ.(x, y) = (-16 + 39k,\; 7 - 17k), \qquad k \in \Z .

For the right-hand side 55, multiply the particular solution by 55: (x,y)=(80+39k,  3517k)(x, y) = (-80 + 39k,\; 35 - 17k), kZk \in \Z.

Exercise 6.5 ★★

Prove that for a,bNa, b \in \N^*: gcd(a,b)×lcm(a,b)=ab\gcd(a,b) \times \operatorname{lcm}(a,b) = ab. (Use the valuation formulas of Proposition 6.16 and min(α,β)+max(α,β)=α+β\min(\alpha,\beta) + \max(\alpha,\beta) = \alpha + \beta.)

Solution

Solution of Exercise 6.5.

For every prime pp, with α=vp(a)\alpha = v_p(a) and β=vp(b)\beta = v_p(b):

vp(gcd(a,b))+vp(lcm(a,b))=min(α,β)+max(α,β)=α+β=vp(ab).v_p\bigl(\gcd(a,b)\bigr) + v_p\bigl(\operatorname{lcm}(a,b)\bigr) = \min(\alpha, \beta) + \max(\alpha, \beta) = \alpha + \beta = v_p(ab) .

Two positive integers with the same valuation at every prime are equal (Proposition 6.16), so gcd(a,b)lcm(a,b)=ab\gcd(a,b)\operatorname{lcm}(a,b) = ab.

Exercise 6.6 ★★

Let a=210×34×52a = 2^{10} \times 3^4 \times 5^2 and b=26×37×7b = 2^6 \times 3^7 \times 7. Compute gcd(a,b)\gcd(a, b), lcm(a,b)\operatorname{lcm}(a,b), and the number of positive divisors of aa. (Prove the divisor-count formula i(αi+1)\prod_i (\alpha_i + 1).)

Solution

Solution of Exercise 6.6.

Valuations: gcd(a,b)=2min(10,6)3min(4,7)5min(2,0)7min(0,1)=2634=5184\gcd(a, b) = 2^{\min(10,6)} 3^{\min(4,7)} 5^{\min(2,0)} 7^{\min(0,1)} = 2^6\, 3^4 = 5184; lcm(a,b)=21037527\operatorname{lcm}(a,b) = 2^{10}\, 3^7\, 5^2\, 7.

Divisor count: a positive divisor of n=piαin = \prod p_i^{\alpha_i} is exactly a choice piβi\prod p_i^{\beta_i} with 0βiαi0 \leq \beta_i \leq \alpha_i (Proposition 6.16); the choices are independent, so there are i(αi+1)\prod_i (\alpha_i + 1) divisors. For aa: (10+1)(4+1)(2+1)=165(10+1)(4+1)(2+1) = 165.

Exercise 6.7 ★★

Prove that p\sqrt p is irrational for every prime pp, using valuations: compare vpv_p of both sides of pq2=r2p q^2 = r^2.

Solution

Solution of Exercise 6.7.

Suppose p=rq\sqrt p = \frac rq with r,qNr, q \in \N^*, i.e. pq2=r2p q^2 = r^2. Apply vpv_p: vp(pq2)=1+2vp(q)v_p(pq^2) = 1 + 2v_p(q) is odd, while vp(r2)=2vp(r)v_p(r^2) = 2 v_p(r) is even. An integer cannot have an odd and an even pp-valuation at once: contradiction. So pQ\sqrt p \notin \Q.

Exercise 6.8 ★★

(Chinese remainder problem) Find all integers xx with

x2(mod7),x5(mod11).x \equiv 2 \pmod 7, \qquad x \equiv 5 \pmod{11}.

Prove along the way that for coprime m,nm, n, the pair of congruences xa (m)x \equiv a \ (m), xb (n)x \equiv b\ (n) always has a solution, unique mod mnmn.

Solution

Solution of Exercise 6.8.

General fact. With gcd(m,n)=1\gcd(m,n) = 1, Bézout gives mu+nv=1mu + nv = 1. Set x0=bmu+anvx_0 = b\,mu + a\,nv. Then x0anva(1mu)a(modm)x_0 \equiv a\,nv \equiv a(1 - mu) \equiv a \pmod m and similarly x0b(modn)x_0 \equiv b \pmod n: existence. If xx and xx' are two solutions, mm and nn divide xxx - x', so mnxxmn \mid x - x' (Theorem 6.8 (2)): uniqueness mod mnmn.

Numerically: m=7m = 7, n=11n = 11: 7×(3)+11×2=17 \times (-3) + 11 \times 2 = 1. So x0=5×7×(3)+2×11×2=105+44=6116(mod77)x_0 = 5 \times 7 \times (-3) + 2 \times 11 \times 2 = -105 + 44 = -61 \equiv 16 \pmod{77}. Check: 16=2×7+22(mod7)16 = 2\times 7 + 2 \equiv 2 \pmod 7; 16=11+55(mod11)16 = 11 + 5 \equiv 5 \pmod{11}. Solutions: x16(mod77)x \equiv 16 \pmod{77}.

Exercise 6.9 ★★

Compute 310003^{1000} mod 77, and the last two decimal digits of 71007^{100} (mod 100=4×25100 = 4 \times 25: use Exercise 6.8).

Solution

Solution of Exercise 6.9.

Mod 77: Fermat gives 3613^6 \equiv 1, and 1000=6×166+41000 = 6 \times 166 + 4, so 3100034=814(mod7)3^{1000} \equiv 3^4 = 81 \equiv 4 \pmod 7.

Last two digits of 71007^{100}: work mod 44 and mod 2525. Mod 44: 717 \equiv -1, so 710017^{100} \equiv 1. Mod 2525: 72=4917^2 = 49 \equiv -1, so 7417^4 \equiv 1 and 7100=(74)2517^{100} = (7^4)^{25} \equiv 1. By the Chinese remainder theorem (Exercise 6.8), 71001(mod100)7^{100} \equiv 1 \pmod{100}: the last two digits are 0101.

Exercise 6.10 ★★★

For m,nNm, n \in \N^*, prove that gcd(2m1,2n1)=2gcd(m,n)1\gcd(2^m - 1,\, 2^n - 1) = 2^{\gcd(m,n)} - 1. Hint: show first that the remainder of 2m12^m - 1 mod 2n12^n - 1 is 2r12^r - 1 where rr is the remainder of mm mod nn; then follow the Euclidean algorithm.

Solution

Solution of Exercise 6.10.

Write m=nq+rm = nq + r, 0r<n0 \leq r < n. Then

2m1=2r(2nq1)+2r1,2^m - 1 = 2^r\bigl(2^{nq} - 1\bigr) + 2^r - 1,

and 2n12^n - 1 divides 2nq1=(2n1)(2n(q1)++1)2^{nq} - 1 = (2^n - 1)(2^{n(q-1)} + \dots + 1). So mod 2n12^n - 1,   2m12r1\;2^m - 1 \equiv 2^r - 1, and since 02r1<2n10 \leq 2^r - 1 < 2^n - 1, this is the Euclidean remainder.

Therefore the Euclidean algorithm on the pair (2m1,2n1)(2^m - 1, 2^n - 1) mirrors, exponent by exponent, the algorithm on (m,n)(m, n): each division step replaces (m,n)(m, n) by (n,r)(n, r) upstairs and (2m1,2n1)(2^m - 1, 2^n - 1) by (2n1,2r1)(2^n - 1, 2^r - 1) downstairs. The algorithm upstairs terminates at gcd(m,n)\gcd(m,n), so downstairs it terminates at 2gcd(m,n)12^{\gcd(m,n)} - 1.

Exercise 6.11 ★★★

(Wilson’s theorem) Let pp be a prime. Prove that

(p1)!1(modp),(p-1)! \equiv -1 \pmod p ,

by pairing each factor of (p1)!(p-1)! with its inverse mod pp and identifying the self-paired factors (solve x21(modp)x^2 \equiv 1 \pmod p first). Check the converse: if n2n \geq 2 is not prime, then (n1)!≢1(modn)(n-1)! \not\equiv -1 \pmod n.

Solution

Solution of Exercise 6.11.

First solve x21(modp)x^2 \equiv 1 \pmod p: p(x1)(x+1)p \mid (x-1)(x+1), so by Euclid’s lemma x1x \equiv 1 or x1(modp)x \equiv -1 \pmod p.

In the product (p1)!=1×2××(p1)(p-1)! = 1 \times 2 \times \dots \times (p-1), every factor aa is invertible mod pp, and its inverse a1a^{-1} is again one of the factors (Proposition 6.20). Pair each aa with a1a^{-1}: the pairs multiply to 11, except that self-paired factors (a=a1a = a^{-1}, i.e. a21a^2 \equiv 1) stand alone — and these are exactly 11 and p1p - 1. Hence

(p1)!1×(p1)1(modp).(p-1)! \equiv 1 \times (p - 1) \equiv -1 \pmod p .

(For p=2p = 2: 1!=11(mod2)1! = 1 \equiv -1 \pmod 2; the pairing argument degenerates but the result holds.)

Converse. Let n2n \geq 2 be composite, n=abn = ab with 1<ab<n1 < a \leq b < n. If a<ba < b, both appear as distinct factors of (n1)!(n-1)!, so n(n1)!n \mid (n-1)! and (n1)!0≢1(n-1)! \equiv 0 \not\equiv -1. If a=ba = b (i.e. n=a2n = a^2): for a3a \geq 3, both aa and 2a2a are <n< n, so n=a2a×2a(n1)!n = a^2 \mid a \times 2a \mid (n-1)!, same conclusion; for n=4n = 4, (n1)!=62≢1(mod4)(n-1)! = 6 \equiv 2 \not\equiv -1 \pmod 4.

Exercise 6.12 ★★★

(Fermat numbers) For nNn \in \N, let Fn=22n+1F_n = 2^{2^n} + 1.

  1. Prove that F0F1Fn1=Fn2F_0 F_1 \cdots F_{n-1} = F_n - 2 for n1n \geq 1 (induction).
  2. Deduce that the Fermat numbers are pairwise coprime.
  3. Deduce a second proof, independent of Theorem 6.14, that there are infinitely many primes.
Solution

Solution of Exercise 6.12.

  1. Induction. For n=1n = 1: F0=3=F12=52F_0 = 3 = F_1 - 2 = 5 - 2. Assuming F0Fn1=Fn2F_0\cdots F_{n-1} = F_n - 2:

    F0Fn=(Fn2)Fn=(22n1)(22n+1)=22n+11=Fn+12.F_0 \cdots F_n = (F_n - 2)F_n = \bigl(2^{2^n} - 1\bigr)\bigl(2^{2^n} + 1\bigr) = 2^{2^{n+1}} - 1 = F_{n+1} - 2 .
  2. Let m<nm < n and d=gcd(Fm,Fn)d = \gcd(F_m, F_n). By (1), FmF_m divides Fn2F_n - 2, so dd divides both FnF_n and Fn2F_n - 2, hence divides 22. But every Fermat number is odd, so d=1d = 1.
  3. Each Fn3F_n \geq 3 has a prime divisor pnp_n (Theorem 6.14’s first step). If mnm \neq n, then pmpnp_m \neq p_n, since a common prime would divide gcd(Fm,Fn)=1\gcd(F_m, F_n) = 1. The map npnn \mapsto p_n is therefore injective from N\N into the primes: there are infinitely many primes.

6.6 Problem: Legendre’s formula and Kummer’s carries

Problem 6.1

How many zeros end the decimal writing of 1000!1000! — and, deeper, what is the exact power of a prime pp dividing n!n!, or dividing a binomial coefficient? The complete answers are two gems of elementary arithmetic: Legendre’s formula vp(n!)=k1n/pkv_p(n!) = \sum_{k\geq1} \lfloor n/p^k \rfloor, with its digital avatar vp(n!)=nsp(n)p1v_p(n!) = \frac{n - s_p(n)}{p-1}, and Kummer’s theorem: vp(m+nm)v_p\binom{m+n}m counts the carries when adding mm and nn in base pp. This problem proves both, checks them against each other numerically, and harvests the classical consequences — trailing zeros, the parity of Pascal’s triangle, and a first bound in the direction of the prime number theorem. Throughout, pp is a prime, x\floor{x} is the integer part, and sp(n)s_p(n) denotes the sum of the digits of nn written in base pp.

Part I — Floors, valuations, and Legendre’s formula.

  1. Warm-up: compute 10!10! and read off its number of trailing zeros; compute v2(10!)v_2(10!) and v5(10!)v_5(10!) directly from the factorization of each factor 1,2,,101, 2, \dots, 10.
  2. Prove that for xRx \in \R and nNn \in \N^*, x/n=x/n\bigl\lfloor \lfloor x \rfloor / n \bigr\rfloor = \lfloor x/n \rfloor.
  3. Prove that vp(a+b)min(vp(a),vp(b))v_p(a + b) \geq \min\bigl(v_p(a), v_p(b)\bigr) for all a,bNa, b \in \N^*, with equality whenever vp(a)vp(b)v_p(a) \neq v_p(b).
  4. Show that the number of multiples of mm in [ ⁣[1,n] ⁣]\intint1n is n/m\lfloor n/m \rfloor.
  5. Prove Legendre’s formula: for every nNn \in \N^*,

    vp(n!)=k=1npkv_p(n!) = \sum_{k=1}^{\infty} \Bigl\lfloor \frac{n}{p^k} \Bigr\rfloor

    (a finite sum: the terms vanish once pk>np^k > n). Count, for each kk, the factors of [ ⁣[1,n] ⁣]\intint1n divisible by pkp^k: each contributes exactly one unit per level it reaches.

Part II — The digital form and trailing zeros.

  1. Compute v5(1000!)v_5(1000!) and v2(1000!)v_2(1000!), and conclude: how many zeros end 1000!1000!?
  2. Prove the digital form of Legendre’s formula: writing n=iaipin = \sum_i a_i p^i in base pp,

    vp(n!)=nsp(n)p1.v_p(n!) = \frac{n - s_p(n)}{p - 1} .
  3. Two consequences for p=2p = 2: show that 2n2^n never divides n!n!, and that 2n12^{n-1} divides n!n! exactly when nn is a power of 22.
  4. Bound the defect: show np1logp(n)1vp(n!)<np1\frac n{p-1} - \log_p(n) - 1 \leq v_p(n!) < \frac n{p-1}, so that vp(n!)n1p1\frac{v_p(n!)}{n} \to \frac1{p-1}: in the long run, a proportion 1p1\frac1{p-1} of one factor pp accrues per unit.
  5. Let Z(n)=v5(n!)Z(n) = v_5(n!) be the number of trailing zeros of n!n!. Show Z(n)Z(n1)=v5(n)Z(n) - Z(n-1) = v_5(n), deduce that ZZ skips the value 55 entirely (compute Z(24)Z(24) and Z(25)Z(25)), and prove that no factorial ends in exactly five zeros.

Part III — Kummer’s theorem.

  1. Prove that x+yxy{0,1}\lfloor x + y \rfloor - \lfloor x \rfloor - \lfloor y \rfloor \in \{0, 1\} for all x,yRx, y \in \R, and deduce from Legendre’s formula that

    vp(m+nm)=k1(m+npkmpknpk),v_p\binom{m+n}m = \sum_{k\geq1}\Bigl( \Bigl\lfloor\frac{m+n}{p^k}\Bigr\rfloor - \Bigl\lfloor\frac{m}{p^k}\Bigr\rfloor - \Bigl\lfloor\frac{n}{p^k}\Bigr\rfloor\Bigr),

    a sum of terms each equal to 00 or 11.

  2. Prove Kummer’s theorem: the kk-th term of that sum equals 11 exactly when the addition of mm and nn in base pp produces a carry into position kk; hence vp(m+nm)v_p\binom{m+n}m is the total number of carries. (Write m=pkm1+m0m = p^km_1 + m_0 and n=pkn1+n0n = p^kn_1 + n_0 with 0m0,n0<pk0 \leq m_0, n_0 < p^k and inspect (m0+n0)/pk\lfloor (m_0 + n_0)/p^k \rfloor.)
  3. Deduce that for 0<j<pk0 < j < p^k:

    vp(pkj)=kvp(j),v_p\binom{p^k}{j} = k - v_p(j) ,

    by counting the carries in the addition j+(pkj)j + (p^k - j). (In particular p(pj)p \mid \binom p j for 0<j<p0 < j < p: the key step of Theorem 6.23, recovered.)

  4. Prove that v2(2nn)=s2(n)v_2\binom{2n}n = s_2(n). Deduce that the central binomial coefficient is always even, and that (2nn)2(mod4)\binom{2n}n \equiv 2 \pmod 4 exactly when nn is a power of 22.
  5. Show, using Vandermonde’s identity (Exercise 2.7) and question 13, that (2pp)2(modp)\binom{2p}p \equiv 2 \pmod p for every prime pp.
  6. Compute v3(1000500)v_3\binom{1000}{500} twice: once by Kummer (write 500500 in base 33 and count the carries in 500+500500 + 500), once by Legendre’s digital form (compute s3(500)s_3(500) and s3(1000)s_3(1000)); check that both give the same value.

Part IV — The parity of Pascal’s triangle, and a prime-density bound.

  1. Prove the digit criterion: (nk)\binom nk is odd if and only if every binary digit of kk is at most the corresponding digit of nn. State and prove the analogous criterion for p(nk)p \nmid \binom nk in base pp.
  2. Deduce that row nn of Pascal’s triangle contains exactly 2s2(n)2^{s_2(n)} odd entries; verify on rows 44 and 55.
  3. Deduce that all interior entries (nk)\binom nk (0<k<n0 < k < n) are even if and only if nn is a power of 22.
  4. Prove that every prime power dividing (m+nm)\binom{m+n}m is at most m+nm + n: if pa(m+nm)p^a \mid \binom{m+n}m then pam+np^a \leq m + n. (How many nonzero terms can the sum of question 11 have?)
  5. Deduce that (2nn)\binom{2n}n divides lcm(1,2,,2n)\operatorname{lcm}(1, 2, \dots, 2n), and combine with the lower bound (2nn)4n2n+1\binom{2n}n \geq \frac{4^n}{2n+1} (which you will prove: the central entry is the largest of the 2n+12n + 1 entries of row 2n2n) to obtain

    lcm(1,,2n)4n2n+1:\operatorname{lcm}(1, \dots, 2n) \geq \frac{4^n}{2n+1} :

    the common multiples of the first integers grow exponentially — a first quantitative glimpse of the abundance of primes.

Part V — Synthesis.

  1. Find the smallest nn such that n!n! ends in at least 20262026 zeros. (Estimate Z(n)n/4Z(n) \approx n/4, then adjust using the exact formula.)
  2. One last cross-check: show that 77 does not divide (10050)\binom{100}{50}, first by writing 5050 in base 77 and checking that the addition 50+5050 + 50 is carry-free, then by computing v7(100!)v_7(100!) and v7(50!)v_7(50!) with Legendre’s formula.
  3. Where exactly did the problem use: (i) unique factorization; (ii) the Euclidean-division decomposition n=pkn1+n0n = p^k n_1 + n_0; (iii) a counting argument from Chapter 2? One sentence each.
  4. Synthesis, in a short paragraph: Legendre’s formula turns a divisibility question into digit arithmetic, and Kummer’s theorem reads the answer off the carries of one addition — comment on this translation, on the checks of question 16, and on what the bound of question 21 suggests about primes (the full statement, the prime number theorem, is far beyond this volume; the polynomial analogue of this chapter’s toolkit is Chapter 8).
Solution

Solution of Problem 6.1.

1. 10!=362880010! = 3\,628\,800: two trailing zeros. Valuations factor by factor: powers of 22 come from 2,4=22,6,8=23,102, 4 = 2^2, 6, 8 = 2^3, 10, totaling v2(10!)=1+2+1+3+1=8v_2(10!) = 1 + 2 + 1 + 3 + 1 = 8; powers of 55 from 55 and 1010: v5(10!)=2v_5(10!) = 2. Trailing zeros =min(v2,v5)=2= \min(v_2, v_5) = 2, consistent.

2. Write the Euclidean division x=nq+r\lfloor x\rfloor = nq + r, 0rn10 \leq r \leq n - 1. Then x=nq+r+{x}x = nq + r + \{x\} with 0r+{x}<n0 \leq r + \{x\} < n, so x/n=q=x/n\lfloor x/n \rfloor = q = \bigl\lfloor \lfloor x \rfloor / n \bigr\rfloor.

3. Let α=vp(a)β=vp(b)\alpha = v_p(a) \leq \beta = v_p(b) (swap if needed) and write a=pαaa = p^\alpha a', b=pβbb = p^\beta b' with pa,bp \nmid a', b'. Then a+b=pα(a+pβαb)a + b = p^\alpha\bigl(a' + p^{\beta - \alpha}b'\bigr), so vp(a+b)α=minv_p(a + b) \geq \alpha = \min. If α<β\alpha < \beta, the parenthesis is a+pβαba≢0(modp)a' + p^{\beta-\alpha}b' \equiv a' \not\equiv 0 \pmod p: the valuation is exactly α\alpha.

4. The multiples of mm in [ ⁣[1,n] ⁣]\intint1n are m,2m,,qmm, 2m, \dots, qm where qq is the largest integer with qmnqm \leq n, i.e. q=n/mq = \lfloor n/m \rfloor.

5. By unique factorization, vp(n!)=j=1nvp(j)v_p(n!) = \sum_{j=1}^{n} v_p(j). Count differently: each jj contributes vp(j)=#{k1:pkj}v_p(j) = \#\{k \geq 1 : p^k \mid j\}, so

vp(n!)=j=1n#{k:pkj}=k1#{jn:pkj}=k1npkv_p(n!) = \sum_{j=1}^n \#\{k : p^k \mid j\} = \sum_{k\geq1} \#\{j \leq n : p^k \mid j\} = \sum_{k\geq1} \Bigl\lfloor \frac n{p^k} \Bigr\rfloor

by question 4 — Legendre’s formula. The sum is finite: terms with pk>np^k > n vanish.

6. v5(1000!)=200+40+8+1=249v_5(1000!) = 200 + 40 + 8 + 1 = 249 (divisions by 5,25,125,6255, 25, 125, 625); v2(1000!)=500+250+125+62+31+15+7+3+1=994v_2(1000!) = 500 + 250 + 125 + 62 + 31 + 15 + 7 + 3 + 1 = 994. Trailing zeros of 1000!1000!: each zero consumes one 22 and one 55, so there are min(994,249)=249\min(994, 249) = 249 of them.

7. With n=iaipin = \sum_i a_ip^i, question 2 gives n/pk=ikaipik\lfloor n/p^k \rfloor = \sum_{i \geq k} a_ip^{i-k} (truncate the base-pp expansion). Summing over k1k \geq 1 and exchanging the two finite sums:

vp(n!)=i1aik=1ipik=i0aipi1p1=nsp(n)p1.v_p(n!) = \sum_{i\geq1} a_i \sum_{k=1}^{i} p^{i-k} = \sum_{i\geq0} a_i\,\frac{p^i - 1}{p - 1} = \frac{n - s_p(n)}{p - 1} .

8. For p=2p = 2: v2(n!)=ns2(n)v_2(n!) = n - s_2(n). Since n1n \geq 1 has s2(n)1s_2(n) \geq 1, always v2(n!)n1<nv_2(n!) \leq n - 1 < n: 2nn!2^n \nmid n!. And v2(n!)=n1v_2(n!) = n - 1 iff s2(n)=1s_2(n) = 1 iff nn is a power of 22.

9. nn has logpn+1\lfloor \log_p n \rfloor + 1 base-pp digits, each at most p1p - 1, so 1sp(n)(p1)(logp(n)+1)1 \leq s_p(n) \leq (p-1)\bigl(\log_p(n) + 1\bigr). Substituting in question 7:

np1logp(n)1    vp(n!)  <  np1,\frac n{p-1} - \log_p(n) - 1 \;\leq\; v_p(n!) \;<\; \frac n{p-1},

and dividing by nn: vp(n!)n1p1\frac{v_p(n!)}n \to \frac1{p-1}.

10. Z(n)Z(n1)=v5(n!/(n1)!)=v5(n)Z(n) - Z(n-1) = v_5(n!/(n-1)!) = v_5(n): the count of trailing zeros jumps by v5(n)v_5(n) at each multiple of 55 and is constant in between. Z(24)=24/5=4Z(24) = \lfloor24/5\rfloor = 4 and Z(25)=5+1=6Z(25) = 5 + 1 = 6: at n=25n = 25 the count jumps from 44 straight to 66 (v5(25)=2v_5(25) = 2), and since ZZ is nondecreasing with Z4Z \leq 4 before and Z6Z \geq 6 after, the value 55 is never attained: no factorial ends in exactly five zeros.

11. Write x=x+{x}x = \lfloor x\rfloor + \{x\}: x+y=x+y+{x}+{y}\lfloor x + y\rfloor = \lfloor x\rfloor + \lfloor y\rfloor + \lfloor \{x\} + \{y\}\rfloor, and 0{x}+{y}<20 \leq \{x\} + \{y\} < 2 makes the last floor 00 or 11. Then, by Legendre applied three times,

vp(m+nm)=vp((m+n)!)vp(m!)vp(n!)=k1(m+npkmpknpk),v_p\binom{m+n}m = v_p\bigl((m{+}n)!\bigr) - v_p(m!) - v_p(n!) = \sum_{k\geq1}\Bigl( \Bigl\lfloor\frac{m+n}{p^k}\Bigr\rfloor - \Bigl\lfloor\frac{m}{p^k}\Bigr\rfloor - \Bigl\lfloor\frac{n}{p^k}\Bigr\rfloor\Bigr),

a finite sum of 00s and 11s (apply the first claim to x=m/pkx = m/p^k, y=n/pky = n/p^k).

12. Fix k1k \geq 1 and write m=pkm1+m0m = p^km_1 + m_0, n=pkn1+n0n = p^kn_1 + n_0 with 0m0,n0<pk0 \leq m_0, n_0 < p^k (Euclidean division: m0m_0 is the number formed by the kk low digits of mm). Then

m+npkmpknpk=m0+n0pk,\Bigl\lfloor\frac{m+n}{p^k}\Bigr\rfloor - \Bigl\lfloor\frac m{p^k}\Bigr\rfloor - \Bigl\lfloor\frac n{p^k}\Bigr\rfloor = \Bigl\lfloor\frac{m_0 + n_0}{p^k}\Bigr\rfloor ,

which is 11 if m0+n0pkm_0 + n_0 \geq p^k and 00 otherwise. But m0+n0pkm_0 + n_0 \geq p^k says precisely that adding the kk low digits of mm and nn overflows into position kk — a carry into position kk in the schoolbook addition algorithm. Summing over kk: vp(m+nm)v_p\binom{m+n}m is the number of carries in the base-pp addition m+nm + n. (Kummer, 1852.)

13. Apply Kummer to m=jm = j, n=pkjn = p^k - j, sum pk=(100k)pp^k = (1\underbrace{0\cdots0}_{k})_p. Let a=vp(j)a = v_p(j), so the base-pp digits of jj at positions 0,,a10, \dots, a-1 are 00 and the digit at position aa is nonzero. The digits of pkjp^k - j below position aa are 00 too (pkj=pa(pkaj/pa)p^k - j = p^a(p^{k-a} - j/p^a)). At position aa, the two nonzero digits must sum to pp (result digit 00): one carry; at each position a+1,,k1a+1, \dots, k-1, digits plus the incoming carry sum to pp (result digit 00 again): the carry propagates. Total: kak - a carries, so vp(pkj)=kvp(j)v_p\binom{p^k}j = k - v_p(j). For k=1k = 1: vp(pj)=1v_p\binom pj = 1 for 0<j<p0 < j < p, the divisibility used in Theorem 6.23.

14. By the digital form (question 7), using s2(2n)=s2(n)s_2(2n) = s_2(n) (appending a zero digit):

v2(2nn)=(2ns2(2n))2(ns2(n))=2s2(n)s2(2n)=s2(n)1:v_2\binom{2n}n = \bigl(2n - s_2(2n)\bigr) - 2\bigl(n - s_2(n)\bigr) = 2s_2(n) - s_2(2n) = s_2(n) \geq 1 :

(2nn)\binom{2n}n is always even, and v2=1v_2 = 1 (i.e. (2nn)2(mod4)\binom{2n}n \equiv 2 \pmod 4) exactly when s2(n)=1s_2(n) = 1, i.e. when nn is a power of 22.

15. Vandermonde with m=n=k=pm = n = k = p: (2pp)=j=0p(pj)(ppj)=j=0p(pj)2\binom{2p}p = \sum_{j=0}^p \binom pj\binom p{p-j} = \sum_{j=0}^p \binom pj^2. For 0<j<p0 < j < p, p(pj)p \mid \binom pj (question 13), so (pj)20(modp)\binom pj^2 \equiv 0 \pmod p; the end terms give 1+11 + 1: (2pp)2(modp)\binom{2p}p \equiv 2 \pmod p.

16. Base 33: 500=486+9+3+2500 = 486 + 9 + 3 + 2, digits (low to high) (2,1,1,0,0,2)(2, 1, 1, 0, 0, 2), so s3(500)=6s_3(500) = 6; and 1000=729+243+27+11000 = 729 + 243 + 27 + 1, digits (1,0,0,1,0,1,1)(1, 0, 0, 1, 0, 1, 1), so s3(1000)=4s_3(1000) = 4. Kummer: add 500+500500 + 500 in base 33: position 00: 2+2=42 + 2 = 4, digit 11 carry 11; position 11: 1+1+1=31 + 1 + 1 = 3, digit 00 carry 11; position 22: 1+1+1=31 + 1 + 1 = 3, digit 00 carry 11; position 33: 0+0+1=10 + 0 + 1 = 1, no carry; position 44: 00; position 55: 2+2=42 + 2 = 4, digit 11 carry 11; position 66: carry lands: digit 11. Four carries: v3(1000500)=4v_3\binom{1000}{500} = 4. Legendre: v3(1000!)=100042=498v_3(1000!) = \frac{1000 - 4}2 = 498 and v3(500!)=50062=247v_3(500!) = \frac{500 - 6}2 = 247, so v3(1000500)=4982×247=4v_3\binom{1000}{500} = 498 - 2\times247 = 4. The two computations agree — and the addition digits (1,0,0,1,0,1,1)(1, 0, 0, 1, 0, 1, 1) reproduce 10001000, as they must.

17. By Kummer (p=2p = 2, m=km = k, n=nkn' = n - k): (nk)\binom nk is odd iff the addition k+(nk)k + (n - k) in base 22 has no carry, iff at every position the digits satisfy ki+(nk)i=nik_i + (n - k)_i = n_i; in that case kinik_i \leq n_i for all ii. Conversely, if kinik_i \leq n_i for all ii, then the number with digits nikin_i - k_i is nkn - k and the addition is carry-free. Same proof in base pp: p(nk)p \nmid \binom nk iff every base-pp digit of kk is at most the corresponding digit of nn.

18. Counting the k[ ⁣[0,n] ⁣]k \in \intint0n whose digits obey kinik_i \leq n_i: each digit of kk is chosen independently among ni+1n_i + 1 values, giving i(ni+1)\prod_i (n_i + 1) choices; in base 22 this is 2#{i:ni=1}=2s2(n)2^{\#\{i : n_i = 1\}} = 2^{s_2(n)}. Row 4=(100)24 = (100)_2: 21=22^1 = 2 odd entries — indeed 1,4,6,4,11, 4, 6, 4, 1 has odd entries only at the ends. Row 5=(101)25 = (101)_2: 22=42^2 = 4 — indeed 1,5,10,10,5,11, 5, 10, 10, 5, 1.

19. All interior entries even     \iff the row has exactly 22 odd entries (the two ends always are odd)     2s2(n)=2    s2(n)=1    n\iff 2^{s_2(n)} = 2 \iff s_2(n) = 1 \iff n is a power of 22.

20. In question 11’s sum, the kk-th term vanishes as soon as pk>m+np^k > m + n (all three floors are then equal, indeed the first is 00 when pk>m+np^k > m+n; more simply each term is 00). Hence at most logp(m+n)\lfloor \log_p(m+n)\rfloor terms are nonzero, each worth 11: a=vp(m+nm)logp(m+n)a = v_p\binom{m+n}m \leq \log_p(m+n), i.e. pam+np^a \leq m + n.

21. For every prime pp, vp(lcm(1,,2n))=logp(2n)v_p\bigl(\operatorname{lcm}(1, \dots, 2n)\bigr) = \lfloor\log_p(2n)\rfloor (the largest power of pp not exceeding 2n2n appears among 1,,2n1, \dots, 2n). Question 20 with m=nm = n gives vp(2nn)logp(2n)v_p\binom{2n}n \leq \lfloor\log_p(2n)\rfloor for every pp: by Proposition 6.16, (2nn)lcm(1,,2n)\binom{2n}n \mid \operatorname{lcm}(1, \dots, 2n). For the size: the ratio (2nk+1)/(2nk)=2nkk+11\binom{2n}{k+1}/\binom{2n}k = \frac{2n-k}{k+1} \geq 1 exactly for k<nk < n, so the central entry is the largest of the 2n+12n + 1 entries of row 2n2n, whence 4n=k(2nk)(2n+1)(2nn)4^n = \sum_k \binom{2n}k \leq (2n+1)\binom{2n}n. Combining:

lcm(1,,2n)(2nn)4n2n+1.\operatorname{lcm}(1, \dots, 2n) \geq \binom{2n}n \geq \frac{4^n}{2n + 1} .

If there were few primes below 2n2n, the lcm could not be this large: exponential growth of the lcm is a quantitative trace of the abundance of primes.

22. Z(n)=kn/5kn4Z(n) = \sum_k\lfloor n/5^k\rfloor \approx \frac n4, so aim near n=4×2026=8104n = 4 \times 2026 = 8104: Z(8104)=1620+324+64+12+2=2022Z(8104) = 1620 + 324 + 64 + 12 + 2 = 2022. Step up by multiples of 55: Z(8110)=2024Z(8110) = 2024, Z(8115)=2025Z(8115) = 2025, and

Z(8120)=1624+324+64+12+2=2026.Z(8120) = 1624 + 324 + 64 + 12 + 2 = 2026 .

Since ZZ is constant between multiples of 55 and Z(8119)=Z(8115)=2025Z(8119) = Z(8115) = 2025, the smallest nn with at least 20262026 trailing zeros is n=8120n = 8120.

23. Base 77: 50=49+150 = 49 + 1, digits (low to high) (1,0,1)(1, 0, 1). Adding 50+5050 + 50: position 00: 1+1=2<71 + 1 = 2 < 7, no carry; position 11: 0+0=00 + 0 = 0; position 22: 1+1=2<71 + 1 = 2 < 7, no carry. Carry-free, so by Kummer v7(10050)=0v_7\binom{100}{50} = 0: 7(10050)7 \nmid \binom{100}{50}. Legendre agrees: v7(100!)=100/7+100/49=14+2=16v_7(100!) = \lfloor 100/7 \rfloor + \lfloor 100/49 \rfloor = 14 + 2 = 16 and v7(50!)=7+1=8v_7(50!) = 7 + 1 = 8, so v7(10050)=162×8=0v_7\binom{100}{50} = 16 - 2\times8 = 0.

24. (i) Unique factorization underlies the very definition of vpv_p and its additivity, hence Legendre’s formula and every divisibility conclusion (Proposition 6.16). (ii) Euclidean division produced the truncation identity of question 2 and the split m=pkm1+m0m = p^km_1 + m_0 that isolates the carry (question 12). (iii) Counting: the multiples-of-mm count (question 4), the digit-choice product (question 18), and the row-sum bound 4n(2n+1)(2nn)4^n \leq (2n+1)\binom{2n}n (question 21) are all Chapter 2-style arguments.

25. Legendre converts “what power of pp divides n!n!” into base-pp digit arithmetic; Kummer compresses the answer for binomial coefficients into the carries of a single addition — divisibility, seemingly a global property of huge numbers, is read off locally, digit by digit. Question 16 is the paradigm: four carries, computed by hand, determine the exact power of 33 in a number with hundreds of digits. And question 21 shows the same circle of ideas brushing against deep waters: an exponential lower bound for lcm(1,,2n)\operatorname{lcm}(1, \dots, 2n) is a first, fully elementary step toward the prime number theorem, whose proof lies far beyond this volume. The entire toolkit — division, gcd, valuations — is replayed for polynomials in Chapter 8, where the analogue of a digit expansion is expansion in powers of (Xa)(X - a).