Divisibility

Contents

Notation

Unless otherwise specified, all variables in these notes are integers.

  • The set of integers is denoted by Z={…,−2,−1,0,1,2,…}\bbZ = \{\ldots, -2, -1, 0, 1, 2, \ldots\}.
  • The set of positive integers, also known as the natural numbers, is denoted by N={1,2,3,…}\bbN = \{1, 2, 3, \ldots\}.

Divisibility

Definition 1 (Divisibility).

We say dd divides nn and write d∣nd \divides n if n=dkn = dk for some k∈Zk \in \bbZ. We also say dd is a divisor of nn, or nn is a multiple of dd.

Symbolically,

d∣n  ⇔  (∃k∈Z)(n=dk).d \divides n \;\Leftrightarrow\; (\exists k \in \bbZ)(n = dk).

Basic Properties.

  1. 1∣n1 \divides n, n∣nn \divides n, and n∣0n \divides 0 for every integer nn.
    (Proof: n=1×nn = 1 \times n, n=n×1n = n \times 1, and 0=n×00 = n \times 0.)
  2. (Transitivity) If a∣ba \divides b and b∣cb \divides c, then a∣ca \divides c.
    (Proof: Write b=akb = ak and c=bmc = bm. Then c=a(km)c = a(km).)
  3. (Linearity) If d∣ad \divides a and d∣bd \divides b, then d∣(ax+by)d \divides (ax + by) for all x,y∈Zx, y \in \bbZ.
    (Proof: Write a=dk1a = dk_1 and b=dk2b = dk_2. Then ax+by=d(k1x+k2y)ax + by = d(k_1 x + k_2 y).)
  4. If a∣ba \divides b and b≠0b \neq 0, then ∣a∣≤∣b∣\lvert a \rvert \leq \lvert b \rvert.
    (Proof: Write b=akb = ak with k≠0k \neq 0, so ∣k∣≥1\lvert k \rvert \geq 1. Then ∣b∣=∣a∣⋅∣k∣≥∣a∣\lvert b \rvert = \lvert a \rvert \cdot \lvert k \rvert \geq \lvert a \rvert.)
  5. If a∣ba \divides b and b∣ab \divides a, then a=±ba = \pm b.
    (Proof: If either is zero, both are zero. Otherwise, by (d), ∣a∣≤∣b∣\lvert a \rvert \leq \lvert b \rvert and ∣b∣≤∣a∣\lvert b \rvert \leq \lvert a \rvert, so ∣a∣=∣b∣\lvert a \rvert = \lvert b \rvert.)

Greatest Common Divisor

Definition 2 (GCD and LCM).

Suppose (a,b)≠(0,0)(a, b) \neq (0, 0). The greatest common divisor (GCD) of aa and bb is the largest integer gg such that g∣ag \divides a and g∣bg \divides b. Symbolically,

gcd⁡(a,b)=max⁡{g∈Z ⁣:g∣a and g∣b}.\gcd(a, b) = \max\left\{ g \in \bbZ \colon g \divides a \text{ and } g \divides b \right\}.

By convention, we define gcd⁡(0,0)=0\gcd(0, 0) = 0 for a reason that will be clear soon. If gcd⁡(a,b)=1\gcd(a, b) = 1, we say that aa and bb are relatively prime (or coprime).

Suppose aa and bb are not both zero. The least common multiple (LCM) of aa and bb is the smallest positive integer mm such that a∣ma \divides m and b∣mb \divides m. Symbolically,

lcm⁡(a,b)=min⁡{m∈N ⁣:a∣m and b∣m}.\lcm(a, b) = \min\left\{ m \in \bbN \colon a \divides m \text{ and } b \divides m \right\}.

By convention, we define lcm⁡(a,0)=lcm⁡(0,a)=0\lcm(a, 0) = \lcm(0, a) = 0 for all a∈Za \in \bbZ.

Given a,b∈Za, b \in \bbZ, a linear combination of aa and bb is any integer of the form ax+byax + by for some x,y∈Zx, y \in \bbZ. The set of all linear combinations of aa and bb is

aZ+bZ={ax+by ⁣:x,y∈Z}.a\bbZ + b\bbZ = \left\{ ax + by \colon x, y \in \bbZ \right\}.

Exercise 3.

Prove that 6Z+10Z=2Z6\bbZ + 10\bbZ = 2\bbZ. In other words, the set of all linear combinations of 66 and 1010 is precisely the set of all multiples of 22.

Hint: Show two inclusions separately. For 6Z+10Z⊆2Z6\bbZ + 10\bbZ \subseteq 2\bbZ, note that 6x+10y=2(3x+5y)6x + 10y = 2(3x + 5y) is always even. For 2Z⊆6Z+10Z2\bbZ \subseteq 6\bbZ + 10\bbZ, find specific integers xx and yy such that 6x+10y=26x + 10y = 2; then every multiple of 22 is a multiple of this linear combination.

Recall that we defined gcd⁡(0,0)=0\gcd(0, 0) = 0. The following proposition holds true even in the special case a=b=0a = b = 0.

Proposition 4.

For any a,b∈Za, b \in \bbZ,

aZ+bZ=gZ,a\bbZ + b\bbZ = g\bbZ,

where g=gcd⁡(a,b)g = \gcd(a, b).

Corollary 5.

If d∣ad \divides a and d∣bd \divides b, then d∣gcd⁡(a,b)d \divides \gcd(a, b).

Proof.

Let g=gcd⁡(a,b)g = \gcd(a, b). By linearity, dd divides every element of aZ+bZ=gZa\bbZ + b\bbZ = g\bbZ. In particular, d∣gd \divides g.

An important application of Proposition 4: the equation ax+by=cax + by = c has integer solutions if and only if gcd⁡(a,b)∣c\gcd(a, b) \divides c, because the left-hand side ranges over all elements of aZ+bZ=gcd⁡(a,b) Za\bbZ + b\bbZ = \gcd(a,b)\,\bbZ.

Exercise 6.

Which of the following equations have integer solutions in xx and yy?

  1. 6x+10y=26x + 10y = 2
  2. 17x−43y=117x - 43y = 1
  3. 9x+30y=459x + 30y = 45
Answers
  1. gcd⁡(6,10)=2\gcd(6, 10) = 2 and 2∣22 \divides 2. Yes. (For instance, x=2x = 2, y=−1y = -1.)
  2. gcd⁡(17,43)=1\gcd(17, 43) = 1 and 1∣11 \divides 1. Yes. (For instance, x=−5x = -5, y=−2y = -2.)
  3. gcd⁡(9,30)=3\gcd(9, 30) = 3 and 3∣453 \divides 45. Yes. (For instance, x=5x = 5, y=0y = 0.)

Remark. What if part (c) asked for 9x+30y=449x + 30y = 44 instead? Since gcd⁡(9,30)=3\gcd(9, 30) = 3 and 3∤443 \nmid 44, there would be no integer solutions.

Once we know that ax+by=nax + by = n has one integer solution, the next proposition describes all of them.

Proposition 7.

Let a,b,n∈Za, b, n \in \bbZ with (a,b)≠(0,0)(a, b) \neq (0, 0). Suppose (x0,y0)(x_0, y_0) is an integer solution to the equation

ax+by=n.ax + by = n.

Then the general integer solution is given by

{x=x0+bkgy=y0−akg\left\{ \begin{aligned} x &= x_0 + \frac{bk}{g} \\ y &= y_0 - \frac{ak}{g} \end{aligned} \right.

where k∈Zk \in \bbZ and g=gcd⁡(a,b)g = \gcd(a, b).

Proof.

Write a′=a/ga' = a/g and b′=b/gb' = b/g. Every pair in the family is a solution, because

a(x0+b′k)+b(y0−a′k)=n+abkg−abkg=n.a(x_0 + b'k) + b(y_0 - a'k) = n + \frac{abk}{g} - \frac{abk}{g} = n.

Conversely, let (x,y)(x, y) be any solution. If b=0b = 0, then a≠0a \neq 0 and g=∣a∣g = \left| a \right|, so the equation forces x=x0x = x_0 while yy is arbitrary; this is exactly the family above, since a′=±1a' = \pm 1. So assume b≠0b \neq 0. Subtracting ax0+by0=nax_0 + by_0 = n from ax+by=nax + by = n and dividing by gg gives

a′(x−x0)=b′(y0−y).a'(x - x_0) = b'(y_0 - y).

By Proposition 4, g=au+bvg = au + bv for some integers u,vu, v; dividing by gg shows 11 is a linear combination of a′a' and b′b', so gcd⁡(a′,b′)=1\gcd(a', b') = 1. Since b′∣a′(x−x0)b' \divides a'(x - x_0), Euclid’s Lemma (Proposition 17 below) gives b′∣(x−x0)b' \divides (x - x_0). Write x−x0=b′kx - x_0 = b'k. Substituting back, a′b′k=b′(y0−y)a'b'k = b'(y_0 - y), and cancelling b′≠0b' \neq 0 gives y=y0−a′ky = y_0 - a'k.

Corollary 8.

Let a,b∈Na, b \in \bbN. The number of lattice points on the line segment connecting (0,0)(0, 0) and (a,b)(a, b), including both endpoints, is gcd⁡(a,b)+1\gcd(a, b) + 1.

Proof.

Write g=gcd⁡(a,b)g = \gcd(a, b). The equation of the line joining (0,0)(0, 0) and (a,b)(a, b) is bx−ay=0bx - ay = 0. By Proposition 7 with the solution (x0,y0)=(0,0)(x_0, y_0) = (0, 0), and replacing kk by −k-k, the general integer solution is

{x=ag ky=bg k\left\{ \begin{aligned} x &= \frac{a}{g}\, k \\ y &= \frac{b}{g}\, k \end{aligned} \right.

where k∈Zk \in \bbZ. The lattice points on the line segment are given by k=0,1,…,gk = 0, 1, \ldots, g.

Example 9.

One solution of 2x+3y=12x + 3y = 1 is (x0,y0)=(2,−1)(x_0, y_0) = (2, -1). Since gcd⁡(2,3)=1\gcd(2, 3) = 1, Proposition 7 gives the general integer solution

{x=2+3ky=−1−2k\left\{ \begin{aligned} x &= 2 + 3k \\ y &= -1 - 2k \end{aligned} \right.

where k∈Zk \in \bbZ. Geometrically, the integer solutions are the lattice points on the line 2x+3y=12x + 3y = 1, and consecutive ones differ by the vector (3,−2)(3, -2). The same spacing holds for every line 2x+3y=n2x + 3y = n.

A square grid with two parallel lines of slope −2/3. The lattice points on each line are marked, spaced 3 units apart horizontally and 2 units apart vertically.
Lattice points on 2x+3y=12x + 3y = 1 (lower line) and 2x+3y=122x + 3y = 12 (upper line).

Proposition 10 (Chicken McNugget Theorem).

Let a,b∈Na, b \in \bbN with gcd⁡(a,b)=1\gcd(a, b) = 1. Consider the set

S={ax+by ⁣:x,y∈Z and x,y≥0}.S = \left\{ ax + by \colon x, y \in \bbZ \text{ and } x, y \geq 0 \right\}.

The largest integer which is not in SS is ab−a−bab - a - b.

This result is also known as the Frobenius coin problem for two coins, or Sylvester’s theorem.

Proof.

First, ab−a−b∉Sab - a - b \notin S. Suppose instead ax+by=ab−a−bax + by = ab - a - b with x,y≥0x, y \geq 0. Then a(x+1)+b(y+1)=aba(x + 1) + b(y + 1) = ab, so a∣b(y+1)a \divides b(y + 1), and Euclid’s Lemma gives a∣(y+1)a \divides (y + 1). Since y+1>0y + 1 > 0, we get y+1≥ay + 1 \geq a. Similarly x+1≥bx + 1 \geq b. But then a(x+1)+b(y+1)≥2ab>aba(x + 1) + b(y + 1) \geq 2ab > ab, a contradiction.

Next, every integer n>ab−a−bn > ab - a - b is in SS. Since gcd⁡(a,b)=1\gcd(a, b) = 1, the equation ax+by=nax + by = n has integer solutions, and by Proposition 7 the values of yy run through y0−aky_0 - ak for all k∈Zk \in \bbZ. Choose kk so that 0≤y≤a−10 \leq y \leq a - 1. Then

ax=n−by≥n−b(a−1)>(ab−a−b)−ab+b=−a,ax = n - by \geq n - b(a - 1) > (ab - a - b) - ab + b = -a,

so x>−1x > -1, that is, x≥0x \geq 0. Hence n∈Sn \in S.

Euclidean Algorithm

Although gcd⁡(a,b)\gcd(a, b) can be read off easily from the prime factorizations of aa and bb, finding those factorizations in the first place is typically far more expensive than computing the GCD directly. The Euclidean algorithm provides a very efficient method for finding gcd⁡(a,b)\gcd(a, b). For simplicity, we focus on the case of two distinct positive integers.

Algorithm 11 (Euclidean Algorithm).

Given positive integers a>b>0a > b > 0, define r0=ar_0 = a, r1=br_1 = b, and for k≥2k \geq 2, define the quotient qk−1q_{k-1} and remainder rkr_k by

rk−2=qk−1 rk−1+rk,0≤rk<rk−1.r_{k-2} = q_{k-1}\, r_{k-1} + r_k, \qquad 0 \leq r_k < r_{k-1}.

The positive remainders form a strictly decreasing sequence r0>r1>⋯>rn>0r_0 > r_1 > \cdots > r_n > 0. The process terminates when rn+1=0r_{n+1} = 0 for some nn. The last nonzero remainder rnr_n is gcd⁡(a,b)\gcd(a, b).

Proof sketch.

At each step, rk−2=qk−1 rk−1+rkr_{k-2} = q_{k-1}\, r_{k-1} + r_k shows that any common divisor of rk−1r_{k-1} and rkr_k also divides rk−2r_{k-2} (by linearity), and any common divisor of rk−2r_{k-2} and rk−1r_{k-1} also divides rk=rk−2−qk−1 rk−1r_k = r_{k-2} - q_{k-1}\, r_{k-1} (again by linearity). Therefore gcd⁡(rk−2,rk−1)=gcd⁡(rk−1,rk)\gcd(r_{k-2}, r_{k-1}) = \gcd(r_{k-1}, r_k) at every step. Chaining these equalities gives

gcd⁡(a,b)=gcd⁡(r0,r1)=⋯=gcd⁡(rn,0)=rn.\gcd(a, b) = \gcd(r_0, r_1) = \cdots = \gcd(r_n, 0) = r_n.

Example 12.

We find gcd⁡(510,374)\gcd(510, 374) using the Euclidean algorithm.

kkrkr_kqkq_k
0510
13741
21362
31021
4343
50

The last nonzero remainder is r4=34r_4 = 34. Therefore, gcd⁡(510,374)=34\gcd(510, 374) = 34.

The Euclidean algorithm can be extended to find integers xx and yy such that ax+by=gcd⁡(a,b)ax + by = \gcd(a, b).

Algorithm 13 (Extended Euclidean Algorithm).

Using the notation of Algorithm 11, define two additional sequences with initial conditions x0=1x_0 = 1, y0=0y_0 = 0, x1=0x_1 = 0, y1=1y_1 = 1, and for k≥2k \geq 2,

xk=xk−2−qk−1 xk−1,yk=yk−2−qk−1 yk−1.x_k = x_{k-2} - q_{k-1}\, x_{k-1}, \qquad y_k = y_{k-2} - q_{k-1}\, y_{k-1}.

All three sequences rkr_k, xkx_k, yky_k satisfy the same recurrence zk=zk−2−qk−1 zk−1z_k = z_{k-2} - q_{k-1}\, z_{k-1}, but with different initial conditions. This common structure ensures that the relation

a xk+b yk=rka\, x_k + b\, y_k = r_k

holds for every kk, which can be verified by induction. In particular, at termination where rn=gcd⁡(a,b)r_n = \gcd(a, b), we obtain a xn+b yn=gcd⁡(a,b)a\, x_n + b\, y_n = \gcd(a, b).

Example 14.

We extend the previous computation to find integers xx and yy such that 510x+374y=34510x + 374y = 34.

kkrkr_kqkq_kxkx_kyky_k
051010
1374101
213621−1-1
31021−2-23
43433−4-4
50

The equation 510x+374y=34510x + 374y = 34 has a solution (x,y)=(3,−4)(x, y) = (3, -4).

Exercise 15.

Use the Extended Euclidean Algorithm to find a solution to 17x−43y=117x - 43y = 1 from Exercise 6(b).

Hint: Rewrite the equation as 43(−y)+17x=143(-y) + 17x = 1 and apply the algorithm with a=43a = 43 and b=17b = 17.

Exercise 16.

2025 AMC 10A, Problem 17

Hint: If dividing AA by NN leaves a remainder of rr, then N∣(A−r)N \divides (A - r). Apply this to both conditions. By linearity, NN divides every linear combination of the two differences, so NN divides their GCD gg, which the Euclidean algorithm finds quickly. Then NN must be one of the divisors of gg, and it must be larger than the remainders. Which divisor of gg satisfies this?

Euclid’s Lemma and Prime Numbers

Proposition 17 (Euclid's Lemma).

If a∣bca \divides bc and gcd⁡(a,b)=1\gcd(a, b) = 1, then a∣ca \divides c.

Proof.

Since gcd⁡(a,b)=1\gcd(a, b) = 1, Proposition 4 guarantees integers x,y∈Zx, y \in \bbZ such that

ax+by=1.ax + by = 1.

Multiplying both sides by cc:

acx+bcy=c.acx + bcy = c.

Now a∣aca \divides ac (trivially) and a∣bca \divides bc (by hypothesis). By linearity, a∣(acx+bcy)=ca \divides (acx + bcy) = c.

Definition 18 (Prime and Composite Numbers).

An integer p>1p > 1 is a prime number if its only positive divisors are 11 and pp itself. An integer n>1n > 1 is a composite number if it is not prime, i.e., n=abn = ab for some integers 1<a,b<n1 < a, b < n.

Remark. The integer 11 is neither prime nor composite. In the terminology of ring theory, 11 is a unit element (it has a multiplicative inverse in Z\bbZ).

Recall that aa and bb are relatively prime when gcd⁡(a,b)=1\gcd(a, b) = 1. This is equivalent to saying that aa and bb share no common prime divisor.

Exercise 19.

Are the following numbers prime or composite?

  1. 299−12^{99} - 1

    Hint: Note that 99=9×1199 = 9 \times 11 is not prime. Use the factorization xk−1=(x−1)(xk−1+xk−2+⋯+1)x^k - 1 = (x - 1)(x^{k-1} + x^{k-2} + \cdots + 1) with x=29x = 2^9 and k=11k = 11.

  2. 299+12^{99} + 1

    Hint: Note that 9999 is odd. When kk is odd, xk+1=(x+1)(xk−1−xk−2+⋯−x+1)x^k + 1 = (x + 1)(x^{k-1} - x^{k-2} + \cdots - x + 1). Apply this with x=2x = 2 and k=99k = 99.

  3. 974+497^4 + 4

    Hint: Use the Sophie Germain identity: a4+4b4=(a2+2b2+2ab)(a2+2b2−2ab)a^4 + 4b^4 = (a^2 + 2b^2 + 2ab)(a^2 + 2b^2 - 2ab). Set a=97a = 97 and b=1b = 1.

Exercise 20.

Suppose nn is a positive integer.

  1. Prove that if 2n−12^n - 1 is prime, then nn must be a prime.

    Hint: If n=abn = ab with a,b>1a, b > 1, then 2n−1=(2a)b−12^n - 1 = (2^a)^b - 1. Use the factorization xb−1=(x−1)(xb−1+⋯+1)x^b - 1 = (x - 1)(x^{b-1} + \cdots + 1) with x=2ax = 2^a to find a nontrivial divisor.

  2. Prove that if 2n+12^n + 1 is prime, then nn must be a power of 22.

    Hint: If nn has an odd factor k>1k > 1, write n=kmn = km. Then 2n+1=(2m)k+12^n + 1 = (2^m)^k + 1. Use the factorization xk+1=(x+1)(xk−1−xk−2+⋯+1)x^k + 1 = (x + 1)(x^{k-1} - x^{k-2} + \cdots + 1) with x=2mx = 2^m to find a nontrivial divisor.

Proposition 21.

If pp is a prime number, then for any a∈Za \in \bbZ, either p∣ap \divides a or gcd⁡(a,p)=1\gcd(a, p) = 1.

Proof.

Let g=gcd⁡(a,p)g = \gcd(a, p). Since gg is a positive divisor of pp and pp is prime, we have g=1g = 1 or g=pg = p. If g=pg = p, then p∣ap \divides a. Otherwise g=1g = 1, meaning gcd⁡(a,p)=1\gcd(a, p) = 1.

Proposition 22.

If pp is a prime number and p∣abp \divides ab, then p∣ap \divides a or p∣bp \divides b.

Proof.

Suppose p∤ap \nmid a. By Proposition 21, gcd⁡(a,p)=1\gcd(a, p) = 1. Since p∣abp \divides ab, Euclid’s Lemma gives p∣bp \divides b.

Proposition 23.

If a∣na \divides n, b∣nb \divides n, and gcd⁡(a,b)=1\gcd(a, b) = 1, then ab∣nab \divides n.

Proof.

Since a∣na \divides n, write n=akn = ak. Then b∣akb \divides ak and gcd⁡(a,b)=1\gcd(a, b) = 1, so Euclid’s Lemma gives b∣kb \divides k. Write k=bmk = bm. Then n=ak=a(bm)=(ab)mn = ak = a(bm) = (ab)m, hence ab∣nab \divides n.

Example 24.

Since gcd⁡(3,5)=1\gcd(3, 5) = 1, the preceding proposition tells us: if 3∣n3 \divides n and 5∣n5 \divides n, then 15∣n15 \divides n.

The coprimality condition gcd⁡(a,b)=1\gcd(a, b) = 1 is essential. For instance, 4∣124 \divides 12 and 6∣126 \divides 12, but 24∤1224 \nmid 12. Here gcd⁡(4,6)=2≠1\gcd(4, 6) = 2 \neq 1, so the proposition does not apply.

Example 25.

2001 AMC 10, Problem 12
Solution

Among any three consecutive integers, one is even and one is a multiple of 33, so their product is always divisible by 66. Since 7∣n7 \divides n and gcd⁡(6,7)=1\gcd(6, 7) = 1, Proposition 23 gives 42∣n42 \divides n. Therefore nn is necessarily divisible by every divisor of 4242: namely 1,2,3,6,7,14,211, 2, 3, 6, 7, 14, 21, and 4242. This eliminates (A), (B), (C), and (E).

The answer is (D). To confirm, take n=5×6×7=210n = 5 \times 6 \times 7 = 210: we have 7∣2107 \divides 210 but 28∤21028 \nmid 210.

Example 26.

Find the smallest positive integer nn such that 7∣(n+2)7 \divides (n + 2) and 11∣(n+2)11 \divides (n + 2).

Solution

Since gcd⁡(7,11)=1\gcd(7, 11) = 1 and both 77 and 1111 divide n+2n + 2, Proposition 23 gives 77∣(n+2)77 \divides (n + 2). The smallest positive nn satisfies n+2=77n + 2 = 77, giving n=75n = 75.

Proposition 27 (Fundamental Theorem of Arithmetic).

Every integer n≥2n \geq 2 can be written as a product of primes

n=p1p2⋯pk,n = p_1 p_2 \cdots p_k,

and this representation is unique up to the order of the factors.

Proof sketch.

Existence. By strong induction. If nn is prime, we are done. If nn is composite, write n=abn = ab with 1<a,b<n1 < a, b < n. By the inductive hypothesis, both aa and bb are products of primes, so n=abn = ab is as well.

Uniqueness. Suppose n=p1p2⋯pk=q1q2⋯qmn = p_1 p_2 \cdots p_k = q_1 q_2 \cdots q_m are two prime factorizations. Since p1∣q1q2⋯qmp_1 \divides q_1 q_2 \cdots q_m, repeated application of Proposition 22 gives p1∣qjp_1 \divides q_j for some jj. Since both are prime, p1=qjp_1 = q_j. Cancel this common factor and repeat; the two factorizations must agree up to reordering.

The 𝑝-adic Valuation

Definition 28 (𝑝-adic Valuation).

Let pp be a prime number and let n≠0n \neq 0 be an integer. The pp-adic valuation of nn is

νp(n)=max⁡{e≥0 ⁣:pe∣n}.\vp(n) = \max\left\{ e \geq 0 \colon p^e \divides n \right\}.

If p∤np \nmid n, then νp(n)=0\vp(n) = 0. If p∣np \divides n but p2∤np^2 \nmid n, then νp(n)=1\vp(n) = 1. In general, νp(n)\vp(n) is the exponent of pp in the prime factorization of ∣n∣\lvert n \rvert.

nnν2(n)\nu_2(n)ν3(n)\nu_3(n)ν5(n)\nu_5(n)
10101
12210
180221

As a concrete illustration, suppose a=p3qa = p^3 q and b=p3q2rb = p^3 q^2 r, where pp, qq, rr are distinct primes. To check whether a∣ba \divides b, compute the quotient:

ba=p3q2rp3q=p3−3 q2−1 r1−0=qr.\frac{b}{a} = \frac{p^3 q^2 r}{p^3 q} = p^{3-3}\, q^{2-1}\, r^{1-0} = qr.

Since the quotient is a positive integer, we conclude a∣ba \divides b.

Proposition 29.

For any nonzero integers aa and bb and any prime pp,

νp(ab)=νp(a)+νp(b).\vp(ab) = \vp(a) + \vp(b).

Proposition 30.

For nonzero integers aa and bb,

a∣b  ⇔  νp(a)≤νp(b) for every prime p.a \divides b \;\Leftrightarrow\; \vp(a) \leq \vp(b) \text{ for every prime } p.

Corollary 31.

For any nonzero integers aa and bb and any prime pp,

νp(gcd⁡(a,b))=min⁡{νp(a), νp(b)},νp(lcm⁡(a,b))=max⁡{νp(a), νp(b)}.\vp(\gcd(a, b)) = \min\left\{ \vp(a),\, \vp(b) \right\}, \qquad \vp(\lcm(a, b)) = \max\left\{ \vp(a),\, \vp(b) \right\}.

Corollary 32.

For any integers aa and bb,

gcd⁡(a,b)⋅lcm⁡(a,b)=∣ab∣.\gcd(a, b) \cdot \lcm(a, b) = \lvert ab \rvert.
Proof sketch.

If a=0a = 0 or b=0b = 0, both sides are 00. Otherwise, for every prime pp,

νp(gcd⁡(a,b))+νp(lcm⁡(a,b))=min⁡(νp(a), νp(b))+max⁡(νp(a), νp(b))=νp(a)+νp(b)=νp(ab).\vp(\gcd(a,b)) + \vp(\lcm(a,b)) = \min\bigl(\vp(a),\, \vp(b)\bigr) + \max\bigl(\vp(a),\, \vp(b)\bigr) = \vp(a) + \vp(b) = \vp(ab).

Corollary 33 (Divisor Counting Formula).

If n=p1a1p2a2⋯pkakn = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k} is the prime factorization of a positive integer nn, then the number of positive divisors of nn is

(a1+1)(a2+1)⋯(ak+1).(a_1 + 1)(a_2 + 1) \cdots (a_k + 1).
Proof sketch.

A positive integer dd divides nn if and only if 0≤νpi(d)≤ai0 \leq \nu_{p_i}(d) \leq a_i for each ii. There are ai+1a_i + 1 independent choices for each exponent.

Example 34.

The number 360=23⋅32⋅5360 = 2^3 \cdot 3^2 \cdot 5 has (3+1)(2+1)(1+1)=24(3+1)(2+1)(1+1) = 24 positive divisors.

Proposition 35.

A positive integer nn is a perfect square if and only if νp(n)\vp(n) is even for every prime pp.

Proof sketch.

If n=m2n = m^2, then νp(n)=νp(m2)=2νp(m)\vp(n) = \vp(m^2) = 2\vp(m), which is even. Conversely, if every νp(n)\vp(n) is even, write n=p12e1⋯pk2ek=(p1e1⋯pkek)2n = p_1^{2e_1} \cdots p_k^{2e_k} = \left(p_1^{e_1} \cdots p_k^{e_k}\right)^2.

Corollary 36.

If pp is prime and p∣n2p \divides n^2, then p2∣n2p^2 \divides n^2.

Proof sketch.

Since p∣n2p \divides n^2, we have νp(n2)≥1\vp(n^2) \geq 1, hence νp(n)≥1\vp(n) \geq 1. Then νp(n2)=2νp(n)≥2\vp(n^2) = 2\vp(n) \geq 2, so p2∣n2p^2 \divides n^2.

Example 37.

If n2n^2 is a multiple of 33, then n2n^2 must be a multiple of 99. Indeed, 3∣n23 \divides n^2 gives ν3(n)≥1\nu_3(n) \geq 1, so ν3(n2)=2ν3(n)≥2\nu_3(n^2) = 2\nu_3(n) \geq 2.

We close with an example that ties together several ideas from this note.

Example 38.

2022 AMC 10A, Problem 7
Solution

We use the fact that lcm⁡(a,b)\lcm(a, b) takes the maximum of each prime’s valuation while gcd⁡(a,b)\gcd(a, b) takes the minimum (Corollary 31). The relevant factorizations are 18=2⋅3218 = 2 \cdot 3^2, 180=22⋅32⋅5180 = 2^2 \cdot 3^2 \cdot 5, 45=32⋅545 = 3^2 \cdot 5, and 15=3⋅515 = 3 \cdot 5.

From lcm⁡(n,18)=180\lcm(n, 18) = 180:

  • max⁡(ν2(n), 1)=2\max(\nu_2(n),\, 1) = 2, so ν2(n)=2\nu_2(n) = 2.
  • max⁡(ν3(n), 2)=2\max(\nu_3(n),\, 2) = 2, so ν3(n)≤2\nu_3(n) \leq 2.
  • max⁡(ν5(n), 0)=1\max(\nu_5(n),\, 0) = 1, so ν5(n)=1\nu_5(n) = 1.

From gcd⁡(n,45)=15\gcd(n, 45) = 15:

  • min⁡(ν3(n), 2)=1\min(\nu_3(n),\, 2) = 1, so ν3(n)=1\nu_3(n) = 1.
  • min⁡(ν5(n), 1)=1\min(\nu_5(n),\, 1) = 1, consistent with ν5(n)=1\nu_5(n) = 1.

Therefore n=22⋅3⋅5=60n = 2^2 \cdot 3 \cdot 5 = 60, and the sum of its digits is 6+0=66 + 0 = 6. The answer is (B).

Practice Problems

  1. 2023 AMC 10A, Problem 12
  2. 2019 AMC 10A, Problem 11
  3. 2005 AMC 12B, Problem 21
  4. 2020 AMC 10A, Problem 15

Solutions

Problem 1

(B) 14. A number is divisible by 55 if and only if its last digit is 00 or 55. The last digit of the reversed number equals the hundreds digit of NN. Since NN is a three-digit number, its hundreds digit cannot be 00, so it must be 55. Thus N∈{500,501,…,599}N \in \{500, 501, \ldots, 599\} and 7∣N7 \divides N. The multiples of 77 in this range run from 504=7×72504 = 7 \times 72 to 595=7×85595 = 7 \times 85, giving 85−72+1=1485 - 72 + 1 = 14.

Problem 2

(C) 37. Since 2019=3×6732019 = 3 \times 673 (both prime), we have 20199=39⋅67392019^9 = 3^9 \cdot 673^9. A divisor 3a⋅673b3^a \cdot 673^b (with 0≤a,b≤90 \leq a, b \leq 9) is a perfect square when both exponents are even: 5×5=255 \times 5 = 25 choices. It is a perfect cube when both are divisible by 33: 4×4=164 \times 4 = 16 choices. It is a perfect sixth power when both are divisible by 66: 2×2=42 \times 2 = 4 choices. By inclusion–exclusion, the count is 25+16−4=3725 + 16 - 4 = 37.

Problem 3

(C) 2. Write n=7k⋅mn = 7^k \cdot m where 7∤m7 \nmid m. The divisor count gives (k+1)⋅d(m)=60(k+1) \cdot d(m) = 60 and (k+2)⋅d(m)=80(k+2) \cdot d(m) = 80. Dividing: k+2k+1=8060=43\frac{k+2}{k+1} = \frac{80}{60} = \frac{4}{3}, so 3k+6=4k+43k + 6 = 4k + 4, hence k=2k = 2.

Problem 4

(E) 23. We have 12!=210⋅35⋅52⋅7⋅1112! = 2^{10} \cdot 3^5 \cdot 5^2 \cdot 7 \cdot 11, giving (11)(6)(3)(2)(2)=792(11)(6)(3)(2)(2) = 792 total divisors. For a perfect square divisor, each prime’s exponent must be even: 66 choices for the exponent of 22 (from {0,2,4,6,8,10}\{0,2,4,6,8,10\}), 33 for 33 (from {0,2,4}\{0,2,4\}), 22 for 55 (from {0,2}\{0,2\}), and 11 each for 77 and 1111 (only {0}\{0\}). This gives 6⋅3⋅2⋅1⋅1=366 \cdot 3 \cdot 2 \cdot 1 \cdot 1 = 36 perfect square divisors. The probability is 36792=122\frac{36}{792} = \frac{1}{22}, so m+n=1+22=23m + n = 1 + 22 = 23.