Divisibility

Study Sheet

Divisibility

What it means for one integer to divide another

The Division Algorithm

Concept
Divides, quotient, remainder

We write a∣ba \mid b ("aa divides bb") when b=akb = ak for some integer kk. For any integer bb and positive aa there are unique integers q,rq, r with b=aq+rb = aq + r and 0≤r<a0 \le r < a — the division algorithm. Divisibility is the case r=0r = 0.

Everything in number theory grows from this one sentence. It says the integers sort into aa classes by remainder, that "divides" is a yes/no question with a computable answer, and that repeated division must terminate — which is what makes the Euclidean algorithm and base representations work. The uniqueness of qq and rr is what lets us say "the remainder" rather than "a remainder". Concretely, aqaq is the largest multiple of aa that does not pass bb, so q=⌊b/a⌋q = \lfloor b/a \rfloor (rounded DOWN, also for negative bb), and rr is the distance from that multiple up to bb.

Example
A positive dividend

Divide b=100b = 100 by a=7a = 7. The multiples of 77 on either side of 100100 are 98=7⋅1498 = 7\cdot14 and 105=7⋅15105 = 7\cdot15. The quotient counts the whole sevens that fit without passing 100100, so q=14q = 14; the remainder is what is left over, r=100−98=2r = 100 - 98 = 2. So 100=7⋅14+2100 = 7\cdot14 + 2, and 0≤2<70 \le 2 < 7 as the theorem demands.

Example
A negative dividend
−60−54−48−42−50r = 46·(−9)steps of 6; the remainder is measured up from the step below
The multiple of 6 at or below −50 is −54; the remainder is the gap of 4 up to −50.

Divide b=−50b = -50 by a=6a = 6. The remainder must be non-negative, so aqaq has to be the multiple of 66 at or BELOW −50-50. That is −54=6⋅(−9)-54 = 6\cdot(-9), not −48-48, which lies above. Then r=−50−(−54)=4r = -50 - (-54) = 4, and −50=6⋅(−9)+4-50 = 6\cdot(-9) + 4. The same answer comes from the formula q=⌊−50/6⌋=⌊−8.33…⌋=−9q = \lfloor -50/6 \rfloor = \lfloor -8.33\ldots \rfloor = -9: rounding down moves left on the number line, even for negatives.

Example
Only the remainder matters

When nn is divided by 99 the remainder is 55. What remainder does 4n+74n + 7 leave? The information "nn leaves remainder 55" means exactly n=9k+5n = 9k + 5 for some integer kk, so substitute: 4n+7=36k+20+7=36k+27=9(4k+3)4n + 7 = 36k + 20 + 7 = 36k + 27 = 9(4k + 3). The remainder is 00, whatever kk is. The 36k36k part is a multiple of 99 and can never affect the remainder — the first glimpse of modular arithmetic, where we will drop such terms from the start.

Side note
Where it goes wrong

A calculator gives −23/5=−4.6-23/5 = -4.6; chopping off the decimals gives q=−4q = -4 and then r=−23−(−20)=−3r = -23 - (-20) = -3, a negative remainder, which the division algorithm forbids. Round down instead: q=−5q = -5 and r=−23+25=2r = -23 + 25 = 2, so −23=5⋅(−5)+2-23 = 5\cdot(-5) + 2. Keep the notation straight as well: a∣ba \mid b is a statement ("5∣205 \mid 20" is true, "20∣520 \mid 5" is false), while a/ba/b is a number.

Try it
Try it: remainder

Find qq and rr for b=−37b = -37, a=8a = 8.

Show the answer

The multiple of 88 at or below −37-37 is −40=8⋅(−5)-40 = 8\cdot(-5), so −37=8(−5)+3-37 = 8(-5) + 3: q=−5q = \mathbf{-5}, r=3r = \mathbf{3}. (Not q=−4q = -4, r=−5r = -5: the remainder must be non-negative.)

Combining Divisibility Facts

Concept
The combination rule
12 = 4·3+20 = 4·5together: 32 = 4·8, still 4 full rows
Multiples of 4 fill complete rows of 4, and so does any sum of them.

If a∣ba \mid b and a∣ca \mid c, then a∣bx+cya \mid bx + cy for all integers x,yx, y. For instance 4∣124 \mid 12 and 4∣204 \mid 20, so 4∣12+20=324 \mid 12 + 20 = 32 and 4∣3⋅12−20=164 \mid 3\cdot12 - 20 = 16. Two more facts complete the toolkit: if a∣ba \mid b and b∣cb \mid c then a∣ca \mid c; and if a∣ba \mid b with b≠0b \ne 0 then ∣a∣≤∣b∣|a| \le |b|.

The proof is one line: b=akb = ak and c=alc = al give bx+cy=a(kx+ly)bx + cy = a(kx + ly), visibly a multiple of aa. The rule is used backwards far more often than forwards. To find what can divide two expressions, combine them so that the variable cancels; whatever divides both must divide what is left, and the size fact then cuts the possibilities down to a finite list of divisors.

Example
A fraction that never reduces

Show that 3n+52n+3\dfrac{3n + 5}{2n + 3} is in lowest terms for every positive integer nn. Suppose dd divides both the numerator and the denominator. Choose multipliers that make nn cancel: 2(3n+5)−3(2n+3)=6n+10−6n−9=12(3n + 5) - 3(2n + 3) = 6n + 10 - 6n - 9 = 1. By the combination rule d∣1d \mid 1, so d=1d = 1: the two never share a factor. (Test n=4n = 4: 1711\tfrac{17}{11}.)

Example
Dividing to find the divisor

Find all positive integers nn with n+2∣n2+10n + 2 \mid n^2 + 10. First divide the polynomial: n2+10=(n+2)(n−2)+14n^2 + 10 = (n + 2)(n - 2) + 14. Since n+2n + 2 divides n2+10n^2 + 10 and also divides (n+2)(n−2)(n + 2)(n - 2), it divides their difference, 1414. The positive divisors of 1414 are 1,2,7,141, 2, 7, 14, and n+2≥3n + 2 \ge 3, so n+2=7n + 2 = 7 or 1414: n=5n = 5 or n=12n = 12. Check: 52+10=35=7⋅55^2 + 10 = 35 = 7\cdot5 and 122+10=154=14⋅1112^2 + 10 = 154 = 14\cdot11.

Example
Divisible by 77 for every nn

Show that 7∣2n+2+32n+17 \mid 2^{n+2} + 3^{2n+1} for all n≥0n \ge 0. First give both powers the same exponent: 2n+2+32n+1=4⋅2n+3⋅9n2^{n+2} + 3^{2n+1} = 4\cdot2^n + 3\cdot9^n. The factorization xn−yn=(x−y)(xn−1+xn−2y+⋯+yn−1)x^n - y^n = (x - y)(x^{n-1} + x^{n-2}y + \cdots + y^{n-1}) shows that 9−2=79 - 2 = 7 divides 9n−2n9^n - 2^n. So split 3⋅9n=3⋅2n+3(9n−2n)3\cdot9^n = 3\cdot2^n + 3(9^n - 2^n), and the whole expression becomes 7⋅2n+3(9n−2n)7\cdot2^n + 3(9^n - 2^n) — a combination of two multiples of 77. (Check n=1n = 1: 8+27=358 + 27 = 35.)

Side note
Where it goes wrong

The rule does not split products or sums. 6∣4⋅9=366 \mid 4\cdot9 = 36, yet 6∤46 \nmid 4 and 6∤96 \nmid 9: the 22 in 66 went into the 44 and the 33 into the 99. Likewise 5∣3+75 \mid 3 + 7 although 55 divides neither. "If a∣bca \mid bc then a∣ba \mid b or a∣ca \mid c" is true only when aa is prime, and proving even that takes the next topic.

Try it
Try it: a divisor of a polynomial

Find all positive integers nn for which n−1∣n2+5n - 1 \mid n^2 + 5.

Show the answer

Divide: n2+5=(n−1)(n+1)+6n^2 + 5 = (n - 1)(n + 1) + 6, so n−1n - 1 must divide 66. For n=1n = 1 the divisor is 00, which divides only 00, so n≥2n \ge 2 and n−1∈{1,2,3,6}n - 1 \in \{1, 2, 3, 6\}, giving n∈{2,3,4,7}n \in \mathbf{\{2, 3, 4, 7\}}. Check n=7n = 7: 54=6⋅954 = 6\cdot9.

Divisibility Rules

Concept
Digit tests

A number is divisible by 2,5,102, 5, 10 according to its last digit; by 44 or 2525 according to its last two digits; by 88 by its last three. By 33 or 99 when its digit sum is; by 1111 when the alternating digit sum is. By 66 when by both 22 and 33.

Every rule is the same idea: 10≡1(mod9)10 \equiv 1 \pmod 9 so a number is congruent to its digit sum mod 99; 10≡−1(mod11)10 \equiv -1 \pmod{11} so it is congruent to its alternating digit sum mod 1111; 102≡0(mod4)10^2 \equiv 0 \pmod 4 so only the last two digits matter mod 44. (The notation ≡\equiv is defined properly in Modular Arithmetic; "Why It Works" below proves the rules without it.) Once you see them this way you can invent rules for 77, 1313, or any modulus you like.

Example
Test 1111

Is 918,082918{,}082 divisible by 1111? Alternate signs along the digits: 9−1+8−0+8−2=229 - 1 + 8 - 0 + 8 - 2 = 22, a multiple of 1111, so yes (918082=11⋅83462918082 = 11\cdot83462). Starting the signs from the left or from the right only changes the sign of the result, which does not affect divisibility.

Example
Test 88

Is 7,352,4167{,}352{,}416 divisible by 88? Since 1000=8⋅1251000 = 8\cdot125, everything from the thousands digit up is a multiple of 88: 7352416=7352⋅1000+4167352416 = 7352\cdot1000 + 416. So only 416416 matters, and 416=8⋅52416 = 8\cdot52. Yes.

Example
Two missing digits

Find all digits a,ba, b making the five-digit number 5a38b‾\overline{5a38b} divisible by 3636. Since 36=4⋅936 = 4\cdot9 with gcd⁡(4,9)=1\gcd(4, 9) = 1, test 44 and 99 separately. For 44: the last two digits 8b‾\overline{8b} must be a multiple of 44, so b∈{0,4,8}b \in \{0, 4, 8\}. For 99: the digit sum 16+a+b16 + a + b must be a multiple of 99, so a+b=2a + b = 2 or 1111. Now match: b=0b = 0 needs a=2a = 2; b=4b = 4 needs a=7a = 7; b=8b = 8 needs a=3a = 3. The numbers are 5238052380, 5738457384 and 5338853388.

Side note
Where it goes wrong

Testing a composite divisor with factors that overlap. A number divisible by 44 and by 66 need not be divisible by 2424: 1212 is a counterexample. "Divisible by aa and by bb" means "divisible by abab" only when gcd⁡(a,b)=1\gcd(a, b) = 1 — so test 2424 as 3⋅83\cdot8, never as 4⋅64\cdot6.

Try it
Try it: fill the digit

For which digit dd is 4d512‾\overline{4d512} divisible by 99?

Show the answer

Digit sum 4+d+5+1+2=12+d4 + d + 5 + 1 + 2 = 12 + d, which must be a multiple of 99. With 0≤d≤90 \le d \le 9 the only choice is 12+d=1812 + d = 18: d=6d = \mathbf{6}.

Why It Works

Existence: among the integers b−akb - ak (k∈Zk \in \mathbb Z) some are non-negative (take kk very negative). Let rr be the smallest non-negative one, with qq the corresponding kk. If r≥ar \ge a then r−a=b−a(q+1)r - a = b - a(q + 1) is a smaller non-negative member, contradiction; so 0≤r<a0 \le r < a. Uniqueness: if aq+r=aq′+r′aq + r = aq\prime + r\prime with both remainders in [0,a)[0, a), then a(q−q′)=r′−ra(q - q\prime) = r\prime - r has absolute value less than aa, so it must be 00. The well-ordering of the non-negative integers — every non-empty set has a least element — is the engine, and it will power almost every proof in this course.

Write n=dk10k+⋯+d1⋅10+d0n = d_k10^k + \cdots + d_1\cdot10 + d_0. Each 10j−1=99…910^j - 1 = 99\ldots9 is a multiple of 99, so n−(dk+⋯+d1+d0)=dk(10k−1)+⋯+d1(10−1)n - (d_k + \cdots + d_1 + d_0) = d_k(10^k - 1) + \cdots + d_1(10 - 1) is a multiple of 99, hence also of 33: nn and its digit sum leave the same remainder. For 1111, each 10j−(−1)j10^j - (-1)^j is a multiple of 1111 — 10+1=1110 + 1 = 11, 100−1=99100 - 1 = 99, 1000+1=1001=11⋅911000 + 1 = 1001 = 11\cdot91 — so nn minus its alternating digit sum d0−d1+d2−⋯d_0 - d_1 + d_2 - \cdots is a multiple of 1111. For 44 and 88, the powers 100100 and 10001000 are themselves multiples, so the higher digits drop out completely.