Skip to main content
AMC 10 & 12

Modular Arithmetic

Working with remainders instead of full values — congruences let you ignore everything about a number except the piece that actually matters.

Two integers are congruent modulo mm, written ab(modm)a \equiv b \pmod m, if they leave the same remainder when divided by mm (equivalently, m(ab)m \mid (a-b)). This relation is reflexive, symmetric, and transitive — it behaves like equality, which is what makes it so useful.

What you can and can’t do

Addition, subtraction, and multiplication are all safe under a fixed modulus: if aba \equiv band cd(modm)c \equiv d \pmod m, then a+cb+da+c \equiv b+d, acbda-c \equiv b-d, andacbd(modm)ac \equiv bd \pmod m, all still modulo mm. Division is the exception —aa has a modular inverse mod mm (an element a1a^{-1} withaa11(modm)a \cdot a^{-1} \equiv 1 \pmod m) if and only if gcd(a,m)=1\gcd(a,m)=1.

Reducing large powers

For computing anmodma^n \bmod m with a huge exponent, look for the point where the powers ofaa start repeating (the multiplicative cycle). Once you know the cycle length, reduce the exponent modulo that length before computing.

Worked example

Problem: Find the remainder when 3473^{47} is divided by 7.

Solution: Compute powers of 3 mod 7 until they repeat:

313, 322, 336, 344, 355, 361(mod7)3^1\equiv3,\ 3^2\equiv2,\ 3^3\equiv6,\ 3^4\equiv4,\ 3^5\equiv5,\ 3^6\equiv1 \pmod 7

The cycle length is 6 (as guaranteed by Fermat’s Little Theorem, since 7 is prime). Reduce the exponent: 47=6×7+547 = 6\times7+5, so 347355(mod7)3^{47}\equiv3^5\equiv5\pmod7.

Practice problems

1.Find 17mod517 \bmod 5 and 3mod5-3 \bmod 5 (using the convention that a remainder is nonnegative).

2.Does 4 have a modular inverse mod 15? If so, find it.

3.Find the remainder when 2202^{20} is divided by 9.

4.Find the last digit of 71007^{100}.