Discrete MathematicsModular Arithmetic and Cryptography1 of 6
Modular Arithmetic and Cryptography · 1

Congruence mod n and Clock Arithmetic

When a calculation only depends on where a repeating cycle lands, like finding the time of day hundreds of hours from now, carrying every full cycle through the arithmetic is wasted work.

1

Wrapping the Number Line Around a Wheel

To find what spot a large number lands on in a repeating cycle, we throw away all the full laps and keep only the leftover steps.

Wrapping the Number Line Around a Wheel
1212
11
22
33
44
55
66
77
88
99
1010
1111
10 o’clock+250 hours=  ?10\text{ o'clock} + 250\text{ hours} = \;?

Text solution:

250=20×12⏟full laps+10⏟leftover\displaystyle \begin{aligned}250 = \underbrace{\laps{20 \times 12}}_{\text{full laps}} + \underbrace{\leftover{10}}_{\text{leftover}}\end{aligned}
10 o’clock+10 hours⟶8 o’clock\displaystyle 10\text{ o'clock} + \leftover{10}\text{ hours} \longrightarrow \spot{8}\text{ o'clock}
00
11
2\htmlClass{lc-blue}{2}
33
44
−8\htmlClass{lc-blue}{-8}
−7-7
−6-6
−5-5
−4-4
−3\htmlClass{lc-blue}{-3}
−2-2
−1-1
00
11
2\htmlClass{lc-blue}{2}
33
44
55
66
7\htmlClass{lc-blue}{7}
88
99
1010
1111
12\htmlClass{lc-blue}{12}
1313
1414
1515
1616
17\htmlClass{lc-blue}{17}
+5\htmlClass{lc-green}{+5}

Winding the number line clockwise through positive integers and counter-clockwise through negative integers groups all integers into 55 infinite stacks on the wheel, with −1-1 landing on spot 4\spot{4}, −2-2 on spot 3\spot{3}, and −5-5 on spot 0\spot{0}.

Wrapping the number line around a 5-spot wheel sorts all positive and negative integers into 5 stacks, with each number in a stack one full lap of 5 from the next.
2

Congruence and the Two Ways to Check It

We now need a symbol to say that two numbers sit in the same stack on a wheel of size nn, along with a fast way to test whether any two numbers belong to the same stack.

Congruence and the Two Ways to Check It
00
11
2\htmlClass{lc-blue}{2}
33
44
7\htmlClass{lc-blue}{7}
17\htmlClass{lc-blue}{17}
7=17  ?\htmlClass{lc-blue}{7} = \htmlClass{lc-blue}{17}\;?

To write that 7\spot{7} and 17\spot{17} land on the same spot on a wheel of size 55, we add a third bar to the equals sign:

7≡⏟lands on thesame spot as17  (mod 5)⏟on a wheel of size 5\displaystyle \spot{7} \mathrel{\underbrace{\equiv}_{\substack{\text{lands on the} \\ \text{same spot as}}}} \spot{17} \;\underbrace{(\text{mod } 5)}_{\text{on a wheel of size } 5}

The (mod 5)(\text{mod } 5) at the end does not apply only to 17\spot{17}; it tells us the wheel size for the whole statement.

We can check whether two numbers a\spot{a} and b\spot{b} sit in the same stack on a wheel of size nn in two ways:

17\displaystyle \spot{17} =3×5+2and7\displaystyle = \laps{3 \times 5} + \leftover{2} \quad\text{and}\quad \spot{7} =1×5+2\displaystyle = \laps{1 \times 5} + \leftover{2}
a≡b(modn)meansn∣(a−b)⏟a−b is amultiple of n\displaystyle \spot{a} \equiv \spot{b} \pmod n \quad\text{means}\quad \underbrace{n \mid (\spot{a} - \spot{b})}_{\substack{\spot{a} - \spot{b}\text{ is a} \\ \text{multiple of }n}}

Text solution:

83−23\displaystyle \spot{83} - \spot{23} =60\displaystyle = \laps{60} =12×5\displaystyle = \laps{12 \times 5}

Because they are separated by 12\laps{12} exact laps of 55, 83\spot{83} and 23\spot{23} land on the same spot on a 5-wheel, so 83≡23(mod5)\spot{83} \equiv \spot{23} \pmod 5.

3

Swapping Numbers in a Stack

When we add, subtract, or multiply numbers on a wheel of size nn, we want to find the final spot without multiplying huge numbers together first.

Swapping Numbers in a Stack
17×23≡  ?  (mod5)\displaystyle 17 \times 23 \equiv \;?\; \pmod 5
00
4949
−1\htmlClass{lc-orange}{-1}
2525

Text solution:

17×23≡2×3(mod5)=6≡1(mod5)\displaystyle \begin{aligned} 17 \times 23 &\equiv \leftover{2} \times \leftover{3} \pmod 5 \\ &= 6 \\ &\equiv \leftover{1} \pmod 5 \end{aligned}
49×49≡(−1)×(−1)(mod50)≡1(mod50)\displaystyle \begin{aligned} 49 \times 49 &\equiv (\leftover{-1}) \times (\leftover{-1}) \pmod{50} \\ &\equiv 1 \pmod{50} \end{aligned}

Swapping either factor for another positive or negative number in its stack changes how many full laps of 55 we throw away, while the product still lands on the exact same spot on the wheel.

Swapping either factor for another positive or negative number on the same spoke changes how many full laps get thrown away, but never where the product lands.
4

Large Powers on the Wheel

Now suppose we want the remainder when a huge power like 31003^{100} is divided by 77, where the number itself is far too large to write out.

Large Powers on the Wheel
3100≡  ?  (mod7)3^{100} \equiv \;?\; \pmod 7
00
11
22
33
44
55
66

Text solution:

31≡3(mod7)32=9≡2(mod7)33≡2×3=6≡−1(mod7)\displaystyle \begin{aligned} 3^1 &\equiv 3 \pmod 7 \\ 3^2 &= 9 \equiv \leftover{2} \pmod 7 \\ 3^3 &\equiv \leftover{2} \times 3 = 6 \equiv \leftover{-1} \pmod 7 \end{aligned}
3100=(33)33×31≡(−1)33×3(mod7)=−1×3=−3(mod7)\displaystyle \begin{aligned} 3^{100} &= (3^3)^{33} \times 3^{\leftover{1}} \\ &\equiv (\leftover{-1})^{33} \times 3 \pmod 7 \\ &= \leftover{-1} \times 3 \\ &= \leftover{-3} \pmod 7 \end{aligned}
−3+7\displaystyle \leftover{-3} + \laps{7} =4\displaystyle = \leftover{4}

So 31003^{100} leaves a remainder of 4\leftover{4} when divided by 77.

5

Writing Proofs with a=b+kna = b + kn

Swapping numbers on a wheel makes calculations fast, but to prove why a rule like swapping works for every modulus nn, we need a way to turn the three-bar symbol ≡\equiv back into an ordinary equals sign.

Writing Proofs with a = b + kn
a≡b(modn)a=  ?\displaystyle \begin{aligned} \given{a} &\equiv \given{b} \pmod n \\ \given{a} &= \;? \end{aligned}

From the Jump View, saying a≡b(modn)\given{a} \equiv \given{b} \pmod n means a\given{a} is just b\given{b} plus some integer number of full laps of nn:

a≡b(modn)⟺a=b+kn⏟k full laps of nfor some integer k\displaystyle \begin{aligned} &\given{a} \equiv \given{b} \pmod n \\ \Longleftrightarrow\quad &\given{a} = \given{b} + \underbrace{\laps{kn}}_{\substack{k\text{ full laps of }n \\ \text{for some integer }k}} \end{aligned}

Text solution:

a\displaystyle \given{a} =b+kn for some integer k,c\displaystyle = \given{b} + \laps{kn} \text{ for some integer } \laps{k}, \qquad \given{c} =d+mn for some integer m\displaystyle = \given{d} + \laps{mn} \text{ for some integer } \laps{m}
ac=(b+kn)(d+mn)=bd+bmn+dkn+kmn2=bd+n(bm+dk+kmn)⏟an integer\displaystyle \begin{aligned} \target{ac} &= (\given{b} + \laps{kn})(\given{d} + \laps{mn}) \\ &= \target{bd} + b\laps{mn} + d\laps{kn} + \laps{kmn^2} \\ &= \target{bd} + \laps{n\underbrace{(bm + dk + kmn)}_{\text{an integer}}} \end{aligned}

Since bm+dk+kmn\laps{bm + dk + kmn} is an integer, ac\target{ac} equals bd\target{bd} plus full laps of nn, which means ac≡bd(modn)\target{ac} \equiv \target{bd} \pmod n.

6

Proof by Cases on a Wheel

Next, suppose we want to prove a divisibility statement for every integer nn, or show that an equation has no integer solutions. Instead of plugging in 3k\laps{3k}, 3k+1\laps{3k} + \leftover{1}, and 3k+2\laps{3k} + \leftover{2} and multiplying out parentheses with kk, we can test the finitely many spots on the wheel directly.

Proof by Cases on a Wheel
Prove that 3∣(n3−n)\displaystyle \text{Prove that } 3 \mid (\target{n^3 - n})
for every integer n.\displaystyle \text{for every integer } n.

Saying an integer is divisible by 33 is the same as saying it lands on spot 0\holds{0} on a 3-wheel:

3∣(n3−n)⟺n3−n≡0(mod3)\displaystyle 3 \mid (\target{n^3 - n}) \quad\Longleftrightarrow\quad \target{n^3 - n} \equiv \holds{0} \pmod 3

Text solution:

Case 1 (n≡0(mod3)):n3−n≡03−0=0(mod3)Case 2 (n≡1(mod3)):n3−n≡13−1=0(mod3)Case 3 (n≡2≡−1(mod3)):n3−n≡(−1)3−(−1)=−1+1=0(mod3)\displaystyle \begin{aligned} &\text{Case 1 } (n \equiv \spot{0} \pmod 3): \\ &\quad \target{n^3 - n} \equiv \spot{0}^3 - \spot{0} = \holds{0} \pmod 3 \\ &\text{Case 2 } (n \equiv \spot{1} \pmod 3): \\ &\quad \target{n^3 - n} \equiv \spot{1}^3 - \spot{1} = \holds{0} \pmod 3 \\ &\text{Case 3 } (n \equiv \spot{2} \equiv \leftover{-1} \pmod 3): \\ &\quad \begin{aligned} \target{n^3 - n} &\equiv (\leftover{-1})^3 - (\leftover{-1}) \\ &= -1 + 1 = \holds{0} \pmod 3 \end{aligned} \end{aligned}

Since every spot on the 3-wheel gives 0(mod3)\holds{0} \pmod 3, n3−n\target{n^3 - n} is divisible by 33 for all integers nn.

n≡0(mod4)  ⟹  n2≡02=0(mod4)n≡1(mod4)  ⟹  n2≡12=1(mod4)n≡2(mod4)  ⟹  n2≡22=4≡0(mod4)n≡3≡−1(mod4)  ⟹  n2≡(−1)2=1(mod4)\displaystyle \begin{aligned} &n \equiv \spot{0} \pmod 4 \\ &\quad \implies \target{n^2} \equiv \spot{0}^2 = \holds{0} \pmod 4 \\ &n \equiv \spot{1} \pmod 4 \\ &\quad \implies \target{n^2} \equiv \spot{1}^2 = \holds{1} \pmod 4 \\ &n \equiv \spot{2} \pmod 4 \\ &\quad \implies \target{n^2} \equiv \spot{2}^2 = 4 \equiv \holds{0} \pmod 4 \\ &n \equiv \spot{3} \equiv \leftover{-1} \pmod 4 \\ &\quad \implies \target{n^2} \equiv (\leftover{-1})^2 = \holds{1} \pmod 4 \end{aligned}

Because squaring any spot on a 4-wheel only ever lands on 0\holds{0} or 1\holds{1}, no integer square can leave a remainder of 2\missed{2} or 3\missed{3} when divided by 44.

7

Why You Cannot Always Cancel in Mod nn

Because addition, subtraction, and multiplication all let us work across ≡\equiv just like an ordinary equals sign, it is tempting to divide or cancel a common factor on both sides of a congruence. However, canceling can turn a true congruence into a false statement.

Why You Cannot Always Cancel in Mod n
00
1\htmlClass{lc-blue}{1}
22
33
4\htmlClass{lc-blue}{4}
55
2×1≡  ?    (mod 6)2×4≡  ?    (mod 6)\begin{aligned} \htmlClass{lc-violet}{2} \times \htmlClass{lc-blue}{1} &\equiv \;?\;\; (\text{mod } 6) \\ \htmlClass{lc-violet}{2} \times \htmlClass{lc-blue}{4} &\equiv \;?\;\; (\text{mod } 6) \end{aligned}

On a wheel of size 66, multiplying 1\spot{1} by 2\multiplier{2} and multiplying 4\spot{4} by 2\multiplier{2} both land on spot 2\crowded{2}, even though 1\spot{1} and 4\spot{4} sit on opposite sides of the wheel:

2×1≡2×4(mod6)(both land on spot 2)1≢4(mod6)(canceling 2 givesa false statement)\displaystyle \begin{aligned} \multiplier{2} \times \spot{1} &\equiv \multiplier{2} \times \spot{4} \pmod 6 \\ &\quad\text{(both land on spot } \crowded{2}\text{)} \\ \spot{1} &\not\equiv \spot{4} \pmod 6 \\ &\quad\text{(canceling } \multiplier{2} \text{ gives} \\ &\quad\text{a false statement)} \end{aligned}
0\htmlClass{lc-green}{0}
1\htmlClass{lc-green}{1}
2\htmlClass{lc-green}{2}
3\htmlClass{lc-green}{3}
4\htmlClass{lc-green}{4}
5\htmlClass{lc-green}{5}
+1\htmlClass{lc-violet}{+1}
0\htmlClass{lc-orange}{0}
1\htmlClass{lc-mute}{1}
2\htmlClass{lc-orange}{2}
3\htmlClass{lc-mute}{3}
4\htmlClass{lc-orange}{4}
5\htmlClass{lc-mute}{5}
+2\htmlClass{lc-violet}{+2}
2×1\htmlClass{lc-violet}{2}\times\htmlClass{lc-blue}{1}
2×4\htmlClass{lc-violet}{2}\times\htmlClass{lc-blue}{4}

When the step size shares a common factor with the wheel size 66, repeated jumps loop back to 00 early and visit the same spots multiple times, which is why two different multiples land on the exact same spot.

On a 6-spot wheel, any step size that shares a common factor with 6 loops back to 0 early and lands different jumps on the same spot.

Key concepts

On a wheel of size nn, two integers are congruent, written a≡b(modn)\spot{a} \equiv \spot{b} \pmod n, when they land on the same spot, either because they leave the same remainder when divided by nn, or because the gap between them is made of exact full laps of nn (a−b=kn\spot{a} - \spot{b} = \laps{kn} for some integer k\laps{k}). When checking whether two numbers like −24\spot{-24} and 11\spot{11} belong to the same stack mod 77, subtract them (11−(−24)=35=5×7\spot{11} - (\spot{-24}) = \laps{35} = \laps{5 \times 7}) rather than dividing negative numbers by 77.

Before adding, subtracting, or multiplying mod nn, swap each number for a small number in its stack. If a number is already small and positive, no swap is needed; if it sits just below a multiple of nn, swap it with a negative step (49≡−1(mod50)49 \equiv \leftover{-1} \pmod{50}). For a huge power like 3100(mod7)3^{100} \pmod 7, walk small powers one step at a time until a power hits 11 or −1\leftover{-1} (33≡6≡−1(mod7)3^3 \equiv 6 \equiv \leftover{-1} \pmod 7), then bundle the exponent (3100=(33)33×313^{100} = (3^3)^{33} \times 3^{\leftover{1}}).

For proofs, pick your approach based on whether the modulus nn is a variable or a fixed number: to prove a general rule starting from a≡b(modn)\given{a} \equiv \given{b} \pmod n for any modulus nn, rewrite the congruence as an equation a=b+kn\given{a} = \given{b} + \laps{kn} and factor nn out at the end; to prove a divisibility or remainder claim for all integers around a fixed number like 33 or 44, leave k\laps{k} out completely and check the finitely many spots 0,1,…,n−1\spot{0, 1, \dots, n - 1} on the wheel. Finally, never cancel a common multiplier across ≡\equiv (2×1≡2×4(mod6)\multiplier{2} \times \spot{1} \equiv \multiplier{2} \times \spot{4} \pmod 6, yet 1≢4(mod6)\spot{1} \not\equiv \spot{4} \pmod 6).

8

Practice

1

Which of the integers −24-24, −18-18, 3939, and 5252 lie on the same spot as 11\spot{11} on a wheel of size 77 (that is, are congruent to 11(mod7)\spot{11} \pmod 7), and what is that spot's standard label in {0,1,2,3,4,5,6}\{0, 1, 2, 3, 4, 5, 6\}?

Use the Jump View: subtract each number from 11\spot{11} and check whether the gap is a multiple of 77.

Check the gap from 11\spot{11} for each number
11−(−24)=35=5×7(yes)11−(−18)=29(not a multiple of 7)39−11=28=4×7(yes)52−11=41(not a multiple of 7)\displaystyle \begin{aligned} \spot{11} - (\spot{-24}) &= \laps{35} = \laps{5 \times 7} \quad\text{(yes)} \\ \spot{11} - (-18) &= \wrong{29} \\ &\quad\text{(not a multiple of } 7\text{)} \\ \spot{39} - \spot{11} &= \laps{28} = \laps{4 \times 7} \quad\text{(yes)} \\ 52 - \spot{11} &= \wrong{41} \\ &\quad\text{(not a multiple of } 7\text{)} \end{aligned}
(Watch out for the double negative in 11−(−24)\spot{11} - (\spot{-24}): dropping a minus sign gives 11−24=−1311 - 24 = \wrong{-13}, which falsely rules out −24\spot{-24}. Likewise, if you divide −24\spot{-24} by 77 directly, −24=−3×7−3-24 = \laps{-3 \times 7} - \leftover{3} is 3\leftover{3} steps behind 00, which is spot 7−3=47 - 3 = \spot{4}, not 3\wrong{3}.)
Find the standard spot label
11\displaystyle \spot{11} =1×7+4≡4(mod7)\displaystyle = \laps{1 \times 7} + \leftover{4} \equiv \leftover{4} \pmod 7
Thus −24\spot{-24} and 39\spot{39} lie on the same spot as 11\spot{11}, and that spot's standard label is 4\spot{4}.
2

Find the remainder when 29×27−6429 \times 27 - 64 is divided by 3030 by swapping each number with a small positive or negative number from its stack mod 3030.

Compare 2929 and 2727 to 3030, and compare 6464 to 2×30=60\laps{2 \times 30} = \laps{60}.

Swap each number with a small number from its stack mod 30
29≡−1(mod30),27≡−3(mod30),64\displaystyle 29 \equiv \leftover{-1} \pmod{30}, \qquad 27 \equiv \leftover{-3} \pmod{30}, \qquad 64 =2×30+4≡4(mod30)\displaystyle = \laps{2 \times 30} + \leftover{4} \equiv \leftover{4} \pmod{30}
Multiply and subtract
29×27−64≡(−1)(−3)−4(mod30)=3−4=−1(mod30)\displaystyle \begin{aligned} &29 \times 27 - 64 \\ &\qquad \equiv (\leftover{-1})(\leftover{-3}) - \leftover{4} \pmod{30} \\ &\qquad = 3 - 4 \\ &\qquad = \leftover{-1} \pmod{30} \end{aligned}
Convert to a standard remainder in {0,…,29}\{0, \dots, 29\}
−1+30\displaystyle \leftover{-1} + \laps{30} =29\displaystyle = \leftover{29}
(Do not stop at −1\leftover{-1} or drop the minus sign to answer 1\wrong{1}: a remainder when dividing by 3030 must be in {0,1,…,29}\{0, 1, \dots, 29\}, and 11 step behind 00 on a 30-wheel is spot 29\spot{29}.) The remainder is 29\leftover{29}.
3

What is the remainder when 21252^{125} is divided by 99?

Walk small powers of 22 on a 9-wheel until a power lands one step behind 99.

Walk powers of 22 mod 99 to hit −1\leftover{-1}
21≡2,22≡4,23\displaystyle 2^1 \equiv 2, \qquad 2^2 \equiv 4, \qquad 2^3 =8≡−1(mod9)\displaystyle = 8 \equiv \leftover{-1} \pmod 9
Bundle the exponent 125125 into groups of 33Since 125=3×41+2125 = 3 \times 41 + \leftover{2},
2125=(23)41×22≡(−1)41×4(mod9)=−1×4=−4(mod9)\displaystyle \begin{aligned} 2^{125} &= (2^3)^{41} \times 2^{\leftover{2}} \\ &\equiv (\leftover{-1})^{41} \times 4 \pmod 9 \\ &= \leftover{-1} \times 4 \\ &= \leftover{-4} \pmod 9 \end{aligned}
(Be careful with the odd exponent 4141 and with the leftover power: treating (−1)41(\leftover{-1})^{41} as +1\wrong{+1} or dropping the negative sign on −4\leftover{-4} gives the wrong answer 4\wrong{4}.)
Add one lap of 99 for the standard remainder
−4+9\displaystyle \leftover{-4} + \laps{9} =5\displaystyle = \leftover{5}
The remainder is 5\leftover{5}.
4

Using the algebraic definition of congruence (a=b+kn\given{a} = \given{b} + \laps{kn} for some integer k\laps{k}), prove that for all integers a,b,c,d\given{a}, \given{b}, \given{c}, \given{d} and any positive integer nn, if a≡b(modn)\given{a} \equiv \given{b} \pmod n and c≡d(modn)\given{c} \equiv \given{d} \pmod n, then a+c≡b+d(modn)\target{a + c} \equiv \target{b + d} \pmod n and a−c≡b−d(modn)\target{a - c} \equiv \target{b - d} \pmod n.

Rewrite each congruence as an equation with its own integer number of laps, then add and subtract the two equations.

Rewrite each congruence as an equationSuppose a≡b(modn)\given{a} \equiv \given{b} \pmod n and c≡d(modn)\given{c} \equiv \given{d} \pmod n. Then
a\displaystyle \given{a} =b+kn for some integer k,c\displaystyle = \given{b} + \laps{kn} \text{ for some integer } \laps{k}, \qquad \given{c} =d+mn for some integer m\displaystyle = \given{d} + \laps{mn} \text{ for some integer } \laps{m}
(Do not use the same letter k\laps{k} in both equations: writing c=d+kn\given{c} = \given{d} + \laps{kn} assumes c−d\given{c} - \given{d} has the exact same number of laps as a−b\given{a} - \given{b}, which makes the subtraction step collapse to (a−c)−(b−d)=0(\target{a - c}) - (\target{b - d}) = 0 instead of proving it for all pairs.)
Add and subtract the equations, then factor out nn
a+c=(b+kn)+(d+mn)=(b+d)+n(k+m)a−c=(b+kn)−(d+mn)=(b−d)+n(k−m)\displaystyle \begin{aligned} \target{a + c} &= (\given{b} + \laps{kn}) + (\given{d} + \laps{mn}) \\ &= (\target{b + d}) + \laps{n(k + m)} \\ \target{a - c} &= (\given{b} + \laps{kn}) - (\given{d} + \laps{mn}) \\ &= (\target{b - d}) + \laps{n(k - m)} \end{aligned}
Since k+m\laps{k + m} and k−m\laps{k - m} are integers, both (a+c)−(b+d)(\target{a + c}) - (\target{b + d}) and (a−c)−(b−d)(\target{a - c}) - (\target{b - d}) are multiples of nn, so a+c≡b+d(modn)\target{a + c} \equiv \target{b + d} \pmod n and a−c≡b−d(modn)\target{a - c} \equiv \target{b - d} \pmod n.
5

Use a wheel of size 55 to prove that for every integer nn, n5−n\target{n^5 - n} is divisible by 55.

Every integer sits on one of the 55 spots mod 55; swap 3≡−2\spot{3} \equiv \leftover{-2} and 4≡−1\spot{4} \equiv \leftover{-1} to keep the fifth powers small.

Test all 55 stacks on the 5-wheelEvery integer nn is congruent to 0,1,2,3,\spot{0}, \spot{1}, \spot{2}, \spot{3}, or 4(mod5)\spot{4} \pmod 5.
n≡0(mod5):n5−n≡05−0=0(mod5)n≡1(mod5):n5−n≡15−1=0(mod5)n≡2(mod5):n5−n≡25−2=30=6×5≡0(mod5)n≡3≡−2(mod5):n5−n≡(−2)5−(−2)=−32+2=−30≡0(mod5)n≡4≡−1(mod5):n5−n≡(−1)5−(−1)=−1+1=0(mod5)\displaystyle \begin{aligned} &n \equiv \spot{0} \pmod 5: \\ &\quad \target{n^5 - n} \equiv \spot{0}^5 - \spot{0} = \holds{0} \pmod 5 \\ &n \equiv \spot{1} \pmod 5: \\ &\quad \target{n^5 - n} \equiv \spot{1}^5 - \spot{1} = \holds{0} \pmod 5 \\ &n \equiv \spot{2} \pmod 5: \\ &\quad \begin{aligned} \target{n^5 - n} &\equiv \spot{2}^5 - \spot{2} \\ &= 30 = \laps{6 \times 5} \\ &\equiv \holds{0} \pmod 5 \end{aligned} \\ &n \equiv \spot{3} \equiv \leftover{-2} \pmod 5: \\ &\quad \begin{aligned} \target{n^5 - n} &\equiv (\leftover{-2})^5 - (\leftover{-2}) \\ &= -32 + 2 = -30 \\ &\equiv \holds{0} \pmod 5 \end{aligned} \\ &n \equiv \spot{4} \equiv \leftover{-1} \pmod 5: \\ &\quad \begin{aligned} \target{n^5 - n} &\equiv (\leftover{-1})^5 - (\leftover{-1}) \\ &= -1 + 1 = \holds{0} \pmod 5 \end{aligned} \end{aligned}
(When substituting n≡−2n \equiv \leftover{-2} into n5−n\target{n^5 - n}, put −2\leftover{-2} in parentheses for both terms: writing −32−2=−34≡1(mod5)-32 - 2 = -34 \equiv \wrong{1} \pmod 5 misses the double negative in −(−2)-(\leftover{-2}).) Because n5−n≡0(mod5)\target{n^5 - n} \equiv \holds{0} \pmod 5 in all 55 cases, n5−n\target{n^5 - n} is divisible by 55 for every integer nn.
6

Find all spots x\spot{x} in {0,1,2,3,4,5,6,7,8,9}\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9\} on a wheel of size 1010 that satisfy 4x≡4×2(mod10)\multiplier{4}\spot{x} \equiv \multiplier{4} \times 2 \pmod{10}, and explain how your answer disproves the claim that you can always cancel a non-zero multiplier in mod 1010.

Test which spots x\spot{x} on the 10-wheel make 4x\multiplier{4}\spot{x} end in the digit 88 (so 4x≡8(mod10)\multiplier{4}\spot{x} \equiv 8 \pmod{10}) rather than canceling the 4\multiplier{4}.

Check all 1010 spots on the 10-wheel for 4x≡8(mod10)\multiplier{4}\spot{x} \equiv \crowded{8} \pmod{10}
4×2\displaystyle \multiplier{4} \times \spot{2} =8≡8(mod10)and4×7\displaystyle = 8 \equiv \crowded{8} \pmod{10} \quad\text{and}\quad \multiplier{4} \times \spot{7} =28\displaystyle = 28 =2×10+8≡8(mod10)\displaystyle = \laps{2 \times 10} + \leftover{8} \equiv \crowded{8} \pmod{10}
None of the other spots in {0,1,…,9}\{0, 1, \dots, 9\} give a multiple of 4\multiplier{4} ending in 8\crowded{8}, so the solutions are x=2\spot{x} = \spot{2} and x=7\spot{x} = \spot{7}. (Canceling the 4\multiplier{4} on both sides right away gives only x=2\spot{x} = \spot{2} and misses x=7\spot{x} = \spot{7}.)
Why this disproves canceling mod 10Because 4\multiplier{4} and 1010 share a common factor of 22, jumping by 4\multiplier{4}s on a 10-wheel repeats its loop every 55 steps, making 4×7≡4×2(mod10)\multiplier{4} \times \spot{7} \equiv \multiplier{4} \times \spot{2} \pmod{10} true even though canceling 4\multiplier{4} gives the false congruence 7≡2(mod10)\spot{7} \equiv \spot{2} \pmod{10}.
7

By checking all possible spots on a wheel of size 44, prove that there are no integers xx and yy such that x2+y2=1003\target{x^2 + y^2} = 1003.

Find all possible spots that a square can land on mod 44, then check all sums of two such spots against the spot where 10031003 lands mod 44.

Find all possible squares mod 4Every integer is congruent to 0,1,2,\spot{0}, \spot{1}, \spot{2}, or 3≡−1(mod4)\spot{3} \equiv \leftover{-1} \pmod 4, so its square is congruent to:
02≡0,12≡1,22\displaystyle \spot{0}^2 \equiv \holds{0}, \qquad \spot{1}^2 \equiv \holds{1}, \qquad \spot{2}^2 =4≡0,(−1)2≡1(mod4)\displaystyle = 4 \equiv \holds{0}, \qquad (\leftover{-1})^2 \equiv \holds{1} \pmod 4
Thus x2\target{x^2} and y2\target{y^2} can each only be 0\holds{0} or 1(mod4)\holds{1} \pmod 4.
Check all possible sums x2+y2(mod4)\target{x^2 + y^2} \pmod 4
0+0\displaystyle 0 + 0 =0,0+1\displaystyle = \holds{0}, \qquad 0 + 1 =1,1+1\displaystyle = \holds{1}, \qquad 1 + 1 =2(mod4)\displaystyle = \holds{2} \pmod 4
(Be sure to include the mixed case 0+1=1(mod4)0 + 1 = \holds{1} \pmod 4: xx and yy do not have to sit in the same stack mod 44.)
Compare with 1003(mod4)1003 \pmod 4
1003\displaystyle 1003 =4×250+3≡3(mod4)\displaystyle = \laps{4 \times 250} + \leftover{3} \equiv \leftover{3} \pmod 4
Since x2+y2\target{x^2 + y^2} can only land on 0,1,\holds{0}, \holds{1}, or 2(mod4)\holds{2} \pmod 4 and 10031003 lands on 3(mod4)\missed{3} \pmod 4, there are no integers xx and yy such that x2+y2=1003\target{x^2 + y^2} = 1003.