AMC // 10
LEARN>NUMBER THEORY>MODULAR ARITHMETIC
// CONCEPT // NUMBER THEORY

MODULAR ARITHMETIC

Reasoning about remainders to solve divisibility, units-digit, and large-exponent problems without heavy computation.

Overview

We write ab(modn)a \equiv b \pmod{n} to mean "aa and bb have the same remainder when divided by nn," or equivalently, nn divides aba - b. For example, 172(mod5)17 \equiv 2 \pmod{5} because 172=15=3517 - 2 = 15 = 3 \cdot 5.

Modular arithmetic turns problems about huge numbers into problems about small residues. Instead of computing 720247^{2024} exactly, you only track what it looks like mod 10, shrinking billions of digits down to a single digit.

AMC 10 problems love modular arithmetic because it appears in at least three guises: units-digit questions (work mod 10), remainder questions (work mod the given divisor), and divisibility tests (mod 9 for digit sums, mod 4 for last two digits, etc.). Recognizing which modulus to use is often the key step.

Key facts

  • Congruence rule: ab(modn)a \equiv b \pmod{n} if and only if n(ab)n \mid (a - b).
  • Addition and multiplication: If aba \equiv b and cd(modn)c \equiv d \pmod{n}, then a+cb+da + c \equiv b + d and acbd(modn)a \cdot c \equiv b \cdot d \pmod{n}. You can reduce before multiplying.
  • Powers cycle: The residues of a1,a2,a3,a^1, a^2, a^3, \ldots mod nn eventually repeat. Find the period and reduce the exponent by that period.
    Common cycles mod 10 (units digits):
    | base mod 10 | cycle | period | |------------|-------|--------| | 1 | 1 | 1 | | 2 | 2, 4, 8, 6 | 4 | | 3 | 3, 9, 7, 1 | 4 | | 4 | 4, 6 | 2 | | 5 | 5 | 1 | | 6 | 6 | 1 | | 7 | 7, 9, 3, 1 | 4 | | 8 | 8, 4, 2, 6 | 4 | | 9 | 9, 1 | 2 |
  • Euler's theorem: If gcd(a,n)=1\gcd(a, n) = 1 then aϕ(n)1(modn)a^{\phi(n)} \equiv 1 \pmod{n}, where ϕ(n)\phi(n) is Euler's totient. For n=pn = p prime, this reduces to Fermat's little theorem: ap11(modp)a^{p-1} \equiv 1 \pmod{p}.
  • Chinese Remainder Theorem (CRT) — light version: If mm and nn are coprime, then knowing x(modm)x \pmod{m} and x(modn)x \pmod{n} uniquely determines x(modmn)x \pmod{mn}. Use this when a problem gives two separate remainder conditions.
  • Division warning: You can divide both sides by kk only if gcd(k,n)=1\gcd(k, n) = 1. Dividing 60(mod6)6 \equiv 0 \pmod{6} by 2 gives 30(mod6)3 \equiv 0 \pmod{6}, which is false.

Worked example 1

What is the units digit of 720257^{2025}?

Work mod 10. The powers of 7 cycle through units digits 7,9,3,17, 9, 3, 1 with period 4.

Divide the exponent: 2025=4506+12025 = 4 \cdot 506 + 1, so 20251(mod4)2025 \equiv 1 \pmod{4}.

Therefore 720257^{2025} has the same units digit as 717^1, which is 7\mathbf{7}.

Worked example 2

Find the remainder when 540+3405^{40} + 3^{40} is divided by 8.

Work mod 8. Note 55(mod8)5 \equiv 5 \pmod{8}. Compute the cycle of 5k(mod8)5^k \pmod{8}: 515,52=251,535,5^1 \equiv 5,\quad 5^2 = 25 \equiv 1,\quad 5^3 \equiv 5,\ldots The cycle has period 2. Since 40 is even, 5401(mod8)5^{40} \equiv 1 \pmod{8}.

Now for 3k(mod8)3^k \pmod{8}: 313,32=91,333,3^1 \equiv 3,\quad 3^2 = 9 \equiv 1,\quad 3^3 \equiv 3,\ldots Period 2 again. Since 40 is even, 3401(mod8)3^{40} \equiv 1 \pmod{8}.

So 540+3401+1=2(mod8)5^{40} + 3^{40} \equiv 1 + 1 = 2 \pmod{8}. The remainder is 2\mathbf{2}.

Common traps

  • Forgetting to reduce the base first. Always reduce each factor mod nn before multiplying; e.g., to work with 97103(mod10)97 \cdot 103 \pmod{10}, use 73=2117 \cdot 3 = 21 \equiv 1.
  • Off-by-one in cycle position. When the exponent is a multiple of the period, the answer is the last element of the cycle, not the first. E.g., 741(mod10)7^4 \equiv 1 \pmod{10}, not 7.
  • Dividing without checking gcd\gcd. You cannot cancel a common factor unless it is coprime to the modulus.
  • Mixing up "remainder" and "residue". Remainders are always non-negative. If you compute a1(modn)a \equiv -1 \pmod{n}, the remainder is n1n - 1, not 1-1.
  • Applying CRT when moduli share a factor. CRT requires the moduli to be pairwise coprime. If they are not, check consistency and adjust.