Modular Arithmetic
Learn clock arithmetic: remainders, a mod n, congruence modulo n, and how to use them for calendars, check digits and the last digit of huge powers.
Definition
Try it now
Interactive Visual
9 o'clock plus 100 hours: watch the laps
12 spots on the dial: mod 12
Start at 9 and move 100 hours forward.
Days of the week are modulo 7: guess first, then watch
7 spots on the dial: mod 7
Where will the hand land? Tap the spot on the dial.
2 + 100 ≡ ? (mod 7)
Start at Wed and move 100 days forward.
Congruent modulo 12: same spot on the dial
12 spots on the dial: mod 12
38 = 3 × 12 + 2
14 = 1 × 12 + 2
38 − 14 = 24 = 2 × 12
38 ≡ 14 (mod 12)
38 and 14 land on the same spot because their difference 24 is a multiple of 12.
Numbers on the spot 2: … -10, 2, 14, 26, 38 …
Last digits of powers of 3 (modulo 10) repeat
10 spots on the dial: mod 10
Multiply by 3 again and again, and keep only the remainder each time.
Interactive Sandbox
Expression Calculator
Try these:
History
No calculations yet
Practice Problems
18 problemsGlossary
- Modulus
- The fixed number you divide by; the remainders are (12 on a clock, 7 for weekdays)
- Remainder
- What is left over after dividing: in with it is
- a mod n
- The remainder of divided by , for example and
- Congruent modulo n
- Two numbers with the same remainder modulo , written ; equivalently divides
- Cycle length
- How many steps it takes until the remainders of powers start to repeat, for example 4 for the last digits of powers of 3
- Check digit
- An extra digit at the end of a code (barcode, ISBN) chosen so that a weighted sum is divisible by 10 or 11
Formula Card
Division with remainder
$r$ is $a \bmod n$, $q$ is the quotient
Congruence
Same remainder, or: the difference is a multiple of $n$
Reduce first
The same works for subtraction and multiplication
Negative numbers
Add a multiple of $n$ until the number lands in $0, \ldots, n - 1$: $-3 + 12 = 9$