What time will it be?
Four questions that look unrelated:
- The overnight train from Mumbai leaves at 21:00 and the journey takes 30 hours. At what time does it arrive?
- 1 January 2026 was a Thursday. What day of the week was it 100 days later?
- In Dar es Salaam, a friend says she will meet you at saa moja asubuhi — “hour one in the morning”. When should you be there?
- What is the last digit of , a number with more than 1700 digits?
Every one of them is answered the same way: throw away whole cycles and keep the remainder. A day has 24 hours, a week has 7 days, a clock face has 12 hours, and last digits repeat every 10. This lesson turns that trick into an arithmetic of its own, proves why it works, and finds something surprising hiding in its multiplication tables.
Wrapping the number line around a clock
Take the number line and wind it around a circle with 12 equally spaced marks. The numbers go once around; then lands on top of , on top of , and so on.
Two numbers land on the same mark exactly when they differ by a whole number of trips around — a multiple of 12. So to find where a number lands, divide by 12 and keep the remainder. Adding means walking forwards around the circle. Nothing else about the number matters.
Remainders and arithmetic modulo n
You know division with remainder: for whole numbers and there is exactly one way to write
Definition— a mod n
The remainder above is called modulo , written . The number is the modulus. It is always one of .
For example because , and because .
Definition— addition and multiplication modulo n
To add modulo , add as usual and take the remainder on division by . To multiply modulo , multiply as usual and take the remainder. The numbers with these two operations are called the integers modulo .
When and leave the same remainder on division by , mathematicians write and say “ is congruent to modulo ”. So and . It is the notation of the clock: “lands on the same mark”.
Here are two complete multiplication tables. Look along each row.
| × mod 6 | 0 | 1 | 2 | 3 | 4 | 5 |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 2 | 3 | 4 | 5 |
| 2 | 0 | 2 | 4 | 0 | 2 | 4 |
| 3 | 0 | 3 | 0 | 3 | 0 | 3 |
| 4 | 0 | 4 | 2 | 0 | 4 | 2 |
| 5 | 0 | 5 | 4 | 3 | 2 | 1 |
| × mod 5 | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 |
| 1 | 0 | 1 | 2 | 3 | 4 |
| 2 | 0 | 2 | 4 | 1 | 3 |
| 3 | 0 | 3 | 1 | 4 | 2 |
| 4 | 0 | 4 | 3 | 2 | 1 |
Modulo 5, every non-zero row is a shuffle of : each remainder appears exactly once. Modulo 6 the rows of , and repeat themselves, and strange things happen: although neither factor is .
Definition— multiplicative partner
A remainder has a partner modulo if some satisfies . Then multiplying by undoes multiplying by , just as multiplying by undoes multiplying by .
Modulo 5: , so and are partners, and . Modulo 6, only and have partners — the rows of never contain a .
Worked examples
Example— The overnight train
Leave at 21:00, travel 30 hours. On a 24-hour clock: , so . The train arrives at 03:00. The quotient is useful too: it is two days later.
Example— One hundred days after a Thursday
A week has 7 days, so only matters: . Fourteen whole weeks change nothing; the extra days move Thursday to Saturday. (1 January 2026 was a Thursday, so 11 April 2026 was a Saturday.)
Example— Swahili time
In much of East Africa the hours of the day are traditionally counted from about sunrise, which near the equator is close to 6 a.m. all year round. So 7 a.m. is saa moja (“hour one”), noon is saa sita (“hour six”) and 1 p.m. is saa saba (“hour seven”). To convert a time on a 12-hour clock, add modulo : , and . So saa moja asubuhi is 7 a.m. (A clock face writes where we write , but it is the same mark.)
Example— Reduce first, then calculate
What is ? Instead of multiplying, reduce first: and , so the answer is . Check: . ✓ The next section proves this shortcut is always allowed.
Example— Negative numbers on the clock
Going back hours from on a 5-hour clock lands on . In symbols, , so . The remainder must be one of , so the answer is not .
Example— Non-example: mod is not division
is (the remainder), not (the quotient as a decimal) and not (the whole-number quotient).
Why reducing first always works
The shortcut “throw away multiples of whenever you like” rests on two theorems.
Theorem— Theorem 1 (sums)
For all whole numbers , and :
Proof
Divide with remainder: and , where and . Adding,
So is a multiple of plus . Adding a multiple of means walking a whole number of times around the clock, which does not change where you land: if with , then , and by the uniqueness of division with remainder, .
∎
Theorem— Theorem 2 (products)
For all whole numbers , and :
Proof
With the same notation, multiply out:
So is a multiple of plus , and as before its remainder is the remainder of .
∎
Together these say: the remainder of a sum or product depends only on the remainders of its parts. That is exactly why the clock arithmetic of the last section is consistent — and why you may reduce at any moment in a long calculation.
Theorem— Theorem 3 (remainders of powers repeat)
For any whole numbers and , the sequence eventually repeats in a cycle.
Proof
By Theorem 2, : each remainder is determined by the one before. There are only possible remainders, so among the first terms two must be equal (the pigeonhole principle). From the first repeat on, the sequence must go round the same loop for ever, because each term determines the next.
∎
Example— The last digit of a huge power
Last digits are remainders modulo 10. The powers of 7 end in because . Then by Theorem 2, and
So ends in 9 — found without computing a 1713-digit number.
Example— Casting out nines
Since , we have , so for every (Theorem 2 again). A number such as therefore leaves the same remainder on division by 9 as its digit sum , and . Accountants and merchants used this for centuries to catch mistakes: is plausible because the digit sums give and . (A check like this can catch an error but never prove an answer right — see check digits.)
Which multiplications can be undone?
Look again at the tables. Modulo 6, only and have partners; modulo 5, every non-zero remainder does. Modulo 12 (try it in the explorer below) only do. What decides?
Theorem— Theorem 4 (a common factor blocks a partner)
If and have a common factor , then has no partner modulo : there is no with .
Proof
Suppose for some whole numbers and . Then . Now divides , so it divides ; and divides , so it divides . Hence divides their difference, which is . But no whole number greater than divides . This contradiction shows no such exists.
∎
So have no partners modulo , and have none modulo . The converse is also true — if and have no common factor greater than 1, then has a partner modulo — but its proof needs Euclid's algorithm, which you will meet in divisibility and the gcd. Here we prove the most important case.
Theorem— Theorem 5 (prime clocks)
If is a prime number, every remainder has a partner modulo .
Proof
We use Euclid's lemma: if a prime divides a product of two whole numbers, it divides one of them (proved in divisibility and the gcd).
Look at the row of in the multiplication table: the remainders of .
- None of them is : if divided with , it would divide or , but both lie strictly between and .
- No two of them are equal: if and left the same remainder with , then would divide the difference , so would divide or ; but .
So the row contains different non-zero remainders. There are only non-zero remainders, so every one of them appears — in particular . The with is the partner.
∎
The same reasoning explains the zero products. If with , then although . Modulo a prime that cannot happen, by Euclid's lemma. Prime clocks behave like ordinary fractions: you can divide by anything except .
Clock arithmetic in Lean
In Lean, a % n is the remainder of a on division by n. First, division with remainder and the range of a remainder (both quoted from Lean's library), and the train and weekday examples, which Lean checks by computing:
/-- **Division with remainder.** Every `a` is `n` times its quotient plus its remainder:
`n · (a / n) + a % n = a`. This applies core Lean's `Nat.div_add_mod`. -/
theorem div_add_mod (a n : Nat) : n * (a / n) + a % n = a := Nat.div_add_mod a n/-- A remainder on division by `n > 0` is always one of `0, 1, …, n - 1`: `a % n < n`.
This applies core Lean's `Nat.mod_lt`. -/
theorem mod_lt (a : Nat) {n : Nat} (hn : 0 < n) : a % n < n := Nat.mod_lt a hn/-- On a 12-hour clock, 29 hours after 9 o'clock it is 2 o'clock: `(9 + 29) mod 12 = 2`. -/
theorem clock_example : (9 + 29) % 12 = 2 := by decide/-- Number the days Monday = 0, Tuesday = 1, …, Sunday = 6. Then 100 days after a Monday is
day `100 mod 7 = 2`, a Wednesday. -/
theorem week_example : (0 + 100) % 7 = 2 := by decideTheorems 1 and 2 are proved exactly as in the human proofs: split a and b into quotient and remainder, regroup, and use the fact that adding a multiple of n does not change a remainder (Nat.mul_add_mod). The calc blocks are the displayed equations of the proofs.
/-- **The remainder of a sum depends only on the remainders.**
`(a + b) mod n = ((a mod n) + (b mod n)) mod n`.
The lesson's proof: write `a = n·q₁ + r₁` and `b = n·q₂ + r₂`. Then
`a + b = n·(q₁ + q₂) + (r₁ + r₂)`, and adding a multiple of `n` never changes a remainder
(`Nat.mul_add_mod`). -/
theorem add_mod_of_division (a b n : Nat) : (a + b) % n = (a % n + b % n) % n := by
-- The two divisions with remainder.
have ha := Nat.div_add_mod a n
have hb := Nat.div_add_mod b n
-- Regroup: `a + b` is a multiple of `n` plus `r₁ + r₂`.
have hsum : a + b = n * (a / n + b / n) + (a % n + b % n) := by
calc a + b = (n * (a / n) + a % n) + (n * (b / n) + b % n) := by rw [ha, hb]
_ = n * (a / n + b / n) + (a % n + b % n) := by rw [Nat.mul_add]; omega
rw [hsum, Nat.mul_add_mod]/-- **The remainder of a product depends only on the remainders.**
`(a · b) mod n = ((a mod n) · (b mod n)) mod n`.
Proof: with `a = n·q₁ + r₁` and `b = n·q₂ + r₂`, expanding gives
`a · b = n·(q₁·b + r₁·q₂) + r₁·r₂`, a multiple of `n` plus `r₁ · r₂`. -/
theorem mul_mod_of_division (a b n : Nat) : (a * b) % n = (a % n * (b % n)) % n := by
have ha := Nat.div_add_mod a n
have hb := Nat.div_add_mod b n
have hprod : a * b = n * (a / n * b + a % n * (b / n)) + a % n * (b % n) := by
calc a * b = (n * (a / n) + a % n) * b := by rw [ha]
_ = n * (a / n) * b + a % n * b := Nat.add_mul _ _ _
_ = n * (a / n) * b + a % n * (n * (b / n) + b % n) := by rw [hb]
_ = n * (a / n * b + a % n * (b / n)) + a % n * (b % n) := by
rw [Nat.mul_add (a % n), Nat.mul_add n, Nat.mul_assoc, ← Nat.add_assoc,
Nat.mul_left_comm (a % n) n]
rw [hprod, Nat.mul_add_mod]/-- The same fact for sums, quoted from core Lean's library (`Nat.add_mod`). Compare
`add_mod_of_division`, which proves it here from division with remainder. -/
theorem add_mod_library (a b n : Nat) : (a + b) % n = (a % n + b % n) % n := Nat.add_mod a b nZero products, Theorem 4, and a use of it:
/-- On a 12-hour clock a product can be `0` although neither factor is:
`3 · 4 = 12 ≡ 0 (mod 12)` while `3 mod 12 = 3` and `4 mod 12 = 4`. -/
theorem zero_product_mod_twelve : (3 * 4) % 12 = 0 ∧ 3 % 12 ≠ 0 ∧ 4 % 12 ≠ 0 := by decide/-- **A common factor blocks a partner.** If some `d > 1` divides both `a` and `n`, then no `b`
has `a · b mod n = 1`.
Proof: `d` divides `a · b`, and `d` divides `n`, so `d` divides the remainder `a · b mod n`
(the remainder is `a · b` minus a multiple of `n`). If that remainder were `1`, then `d` would
divide `1`, so `d = 1`, contradicting `d > 1`. -/
theorem no_partner_of_common_factor {a n d : Nat} (hd : 1 < d) (hda : d ∣ a) (hdn : d ∣ n)
(b : Nat) : (a * b) % n ≠ 1 := by
intro h
-- `d` divides `a · b` …
have hab : d ∣ a * b := Nat.dvd_mul_right_of_dvd hda b
-- … so it divides the remainder of `a · b` on division by `n`, which is `1`.
have h1 : d ∣ (a * b) % n := (Nat.dvd_mod_iff hdn).mpr hab
rw [h] at h1
have : d = 1 := Nat.eq_one_of_dvd_one h1
omega/-- `4` has no partner modulo `10`: `4` and `10` share the factor `2`. This is
`no_partner_of_common_factor` with `d = 2`. -/
theorem four_no_partner_mod_ten (b : Nat) : (4 * b) % 10 ≠ 1 :=
no_partner_of_common_factor (d := 2) (by decide) (by decide) (by decide) bLean has clock arithmetic built in: Fin 12 is the set of numbers , and its * multiplies and then takes the remainder on division by 12. For one particular clock, decide can simply try every case — 144 products for the 12-hour clock:
/-- On a 12-hour clock exactly `1, 5, 7, 11` have a multiplicative partner. Lean's `Fin 12`
is clock arithmetic: its numbers are `0, …, 11` and `*` multiplies and takes the remainder.
`decide` checks all 144 products. -/
theorem partners_mod_twelve :
∀ a : Fin 12, (∃ b : Fin 12, a * b = 1) ↔ (a = 1 ∨ a = 5 ∨ a = 7 ∨ a = 11) := by
decide/-- Modulo the prime `7`, every non-zero remainder has a partner
(`1·1`, `2·4`, `3·5`, `6·6` all leave remainder `1`). `decide` checks every case. -/
theorem partners_mod_seven : ∀ a : Fin 7, a ≠ 0 → ∃ b : Fin 7, a * b = 1 := by decide/-- Modulo `7`, multiplying by a non-zero `a` never sends two different remainders to the
same place: each row of the multiplication table is a shuffle of `0, …, 6`. (This is the
property check digits rely on.) -/
theorem row_is_shuffle_mod_seven :
∀ a x y : Fin 7, a ≠ 0 → a * x = a * y → x = y := by decideThese three are checked case by case for one modulus each; Theorem 5 for every prime is not formalised here (it needs Euclid's lemma, which is formalised in the lesson on divisibility). Finally, the repeating patterns, proved for all by induction — the formal version of “and so on for ever”:
/-- The powers of `2` modulo `7` repeat `1, 2, 4, 1, 2, 4, …`. In particular
`2^(3k) mod 7 = 1` for every `k`.
Proof by induction: `2^(3(k+1)) = 2^(3k) · 8`, and `8 mod 7 = 1`, so by
`mul_mod_of_division` the remainder is `1 · 1 = 1`. -/
theorem pow_three_mod_seven (k : Nat) : 2 ^ (3 * k) % 7 = 1 := by
induction k with
| zero => decide
| succ k ih =>
calc 2 ^ (3 * (k + 1)) % 7 = (2 ^ (3 * k) * 8) % 7 := by
rw [Nat.mul_succ, Nat.pow_add]
_ = (2 ^ (3 * k) % 7 * (8 % 7)) % 7 := mul_mod_of_division _ _ _
_ = 1 := by rw [ih]/-- The last digit of `7^(4k + 2)` is always `9`: the last digits of `7, 49, 343, 2401, …`
repeat `7, 9, 3, 1`. Proof: `7^4 = 2401` leaves remainder `1` on division by `10`, so
`7^(4k) mod 10 = 1` by induction, and `7^2 = 49`. For example, `7^2026` ends in `9`. -/
theorem last_digit_seven_pow (k : Nat) : 7 ^ (4 * k + 2) % 10 = 9 := by
have h4 : ∀ j : Nat, 7 ^ (4 * j) % 10 = 1 := by
intro j
induction j with
| zero => decide
| succ j ih =>
calc 7 ^ (4 * (j + 1)) % 10 = (7 ^ (4 * j) * 2401) % 10 := by
rw [Nat.mul_succ, Nat.pow_add]
_ = (7 ^ (4 * j) % 10 * (2401 % 10)) % 10 := mul_mod_of_division _ _ _
_ = 1 := by rw [ih]
calc 7 ^ (4 * k + 2) % 10 = (7 ^ (4 * k) * 49) % 10 := by rw [Nat.pow_add]
_ = (7 ^ (4 * k) % 10 * (49 % 10)) % 10 := mul_mod_of_division _ _ _
_ = 9 := by rw [h4 k]/-- `10^k mod 9 = 1` for every `k`, because `10 = 9 + 1` leaves remainder `1`. This is why a
number and the sum of its digits leave the same remainder on division by `9`
("casting out nines"). -/
theorem ten_pow_mod_nine (k : Nat) : 10 ^ k % 9 = 1 := by
induction k with
| zero => decide
| succ k ih =>
calc 10 ^ (k + 1) % 9 = (10 ^ k * 10) % 9 := by rw [Nat.pow_succ]
_ = (10 ^ k % 9 * (10 % 9)) % 9 := mul_mod_of_division _ _ _
_ = 1 := by rw [ih]In Mathlib, the integers modulo form the ring ZMod n, congruence is Nat.ModEq, and the partner of a number coprime to is built by ZMod.unitOfCoprime.
Every clock up to 30
"""Clock arithmetic by machine: reduce-first rules, partners and zero products.
For every modulus n from 2 to 30 the experiment builds the multiplication
table modulo n and finds which remainders a have a partner b with
a * b mod n = 1. It compares that list with the remainders that share no
factor greater than 1 with n, and it searches for "zero products" a * b = 0
with neither factor 0. It also checks the reduce-first rules for sums and
products on a finite range. Everything is exact integer arithmetic over finite
ranges: exhaustive evidence for those n, not a proof for every n.
"""
import math
def partners(n):
"""Remainders a in 0..n-1 that have some b with a * b mod n == 1."""
if n < 1:
raise ValueError("n must be positive")
return [a for a in range(n) if any(a * b % n == 1 for b in range(n))]
def partner_of(a, n):
"""The b in 0..n-1 with a * b mod n == 1, or None if there is none."""
for b in range(n):
if a * b % n == 1:
return b
return None
def coprime_remainders(n):
"""Remainders a in 0..n-1 with gcd(a, n) == 1 (no common factor > 1)."""
return [a for a in range(n) if math.gcd(a, n) == 1 and n > 1]
def zero_products(n):
"""Pairs (a, b) of non-zero remainders with a * b mod n == 0."""
return [(a, b) for a in range(1, n) for b in range(1, n) if a * b % n == 0]
def reduce_first_failures(n_max, a_max):
"""Count cases and failures of the sum and product rules (n = 1..n_max)."""
cases = failures = 0
for n in range(1, n_max + 1):
for a in range(a_max):
for b in range(a_max):
cases += 1
if (a + b) % n != (a % n + b % n) % n:
failures += 1
if (a * b) % n != (a % n) * (b % n) % n:
failures += 1
return cases, failures
def is_prime(n):
"""Trial division (n >= 2)."""
return n >= 2 and all(n % d for d in range(2, math.isqrt(n) + 1))
def main():
cases, bad = reduce_first_failures(30, 120)
print(f"Reduce-first rules, a, b < 120, n <= 30: {cases} cases, {bad} failures")
print()
print("Who has a partner?")
for n in (10, 11, 12):
pairs = ", ".join(f"{a}*{partner_of(a, n)}" for a in partners(n))
print(f" mod {n:<2}: {pairs}")
same = all(partners(n) == coprime_remainders(n) for n in range(2, 31))
print(f" partners = remainders coprime to n, for n = 2..30: {same}")
full = [n for n in range(2, 31) if len(partners(n)) == n - 1]
print(" n for which every non-zero remainder has a partner:")
print(f" {full}")
primes = [n for n in range(2, 31) if is_prime(n)]
print(f" these n are exactly the primes up to 30: {full == primes}")
print()
print("Zero products (a * b = 0 with a, b non-zero):")
for n in (7, 10, 12):
zs = zero_products(n)
shown = ", ".join(f"{a}*{b}" for a, b in zs if a <= b)
print(f" mod {n:<2}: {shown or 'none'}")
no_zero = [n for n in range(2, 31) if not zero_products(n)]
print(f" n <= 30 with no zero products: {no_zero}")
print()
print("Epistemic status: exhaustive, exact evidence for the moduli and ranges")
print("shown, nothing more. The reduce-first rules and 'a common factor blocks")
print("a partner' are proved in the lesson for every n; 'coprime implies a")
print("partner' is proved later with Euclid's algorithm.")
if __name__ == "__main__":
main()The output agrees with Theorems 4 and 5 and with the converse we have not proved yet: the remainders with partners are exactly those sharing no factor with , and the moduli with no zero products are exactly the primes. For that is exhaustive evidence; for larger it is the theorems that do the work.
"""Repeating patterns: last digits of powers, weekdays and calendar cycles.
Remainders of powers must eventually repeat, because there are only n
possible remainders. The experiment finds the repeating cycle of base^k mod n
for some bases (for n = 10 these are last digits), uses a cycle to get the
last digit of a huge power without computing the power, and checks the answer
against Python's exact pow. It then steps two calendar cycles forward day by
day until they line up again (the Chinese 10-stem and 12-branch cycle, and the
Maya 260-day and 365-day counts) and compares with the least common multiple.
All arithmetic is exact; each check covers only the cases printed.
"""
import math
def power_cycle(base, n):
"""Return (start, cycle) for the remainders base^k mod n, k = 0, 1, 2, ...
``start`` is the first k where the repeating part begins and ``cycle``
lists one full period of remainders.
"""
if n < 1:
raise ValueError("n must be positive")
seen = {}
values = []
r = 1 % n
k = 0
while r not in seen:
seen[r] = k
values.append(r)
r = r * base % n
k += 1
start = seen[r]
return start, values[start:]
def remainder_from_cycle(base, exponent, n):
"""base^exponent mod n read off the cycle (no huge power is computed)."""
start, cycle = power_cycle(base, n)
if exponent < start:
return pow(base, exponent, n)
return cycle[(exponent - start) % len(cycle)]
def realign(p, q):
"""Step a p-cycle and a q-cycle together; first day > 0 both are at 0."""
day, a, b = 0, 0, 0
while True:
day, a, b = day + 1, (a + 1) % p, (b + 1) % q
if a == 0 and b == 0:
return day
WEEKDAYS = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday",
"Saturday", "Sunday"]
def weekday_after(start, days):
"""Name of the weekday ``days`` days after the weekday named ``start``."""
return WEEKDAYS[(WEEKDAYS.index(start) + days) % 7]
def main():
print("Cycles of remainders of powers (k = 0, 1, 2, ...):")
for base, n in [(2, 10), (3, 10), (7, 10), (2, 7), (4, 12)]:
start, cycle = power_cycle(base, n)
print(f" {base}^k mod {n:<2}: starts repeating at k = {start}, "
f"cycle {cycle}")
predicted = remainder_from_cycle(7, 2026, 10)
exact = pow(7, 2026) % 10
digits = len(str(pow(7, 2026)))
print(f"Last digit of 7^2026 from the cycle: {predicted}; exact: {exact}")
print(f" (7^2026 has {digits} digits; the cycle needed only 4 numbers)")
print()
print("Weekdays: 1 January 2026 was a Thursday.")
for days in (7, 100, 365):
print(f" {days:>3} days later: {weekday_after('Thursday', days)}")
print()
print("Two cycles running side by side, stepped one at a time:")
for p, q, name in [(10, 12, "Chinese stems and branches (years)"),
(260, 365, "Maya tzolk'in and haab' (days)")]:
print(f" {name}:")
print(f" {p} and {q} realign after {realign(p, q)} steps;"
f" lcm({p}, {q}) = {math.lcm(p, q)}")
print()
print("Epistemic status: exact computations, each checked only for the")
print("cases printed. That powers must repeat is a proof (there are only n")
print("remainders); that a cycle of length 4 continues forever for 7^k mod 10")
print("is proved in the lesson from 7^4 = 2401 and the product rule.")
if __name__ == "__main__":
main()The Chinese calendar names years by pairing one of 10 heavenly stems with one of 12 earthly branches, both advancing each year; the pairs repeat after years, not , because is the first number that is a multiple of both and . The Maya ran a 260-day count and a 365-day count side by side; the pair of dates repeats only after days, about 52 years — the Calendar Round.
Explore: clocks and calendars
In the Add tab, choose the number of hours , a starting time and an amount to add; the hand jumps to the remainder. Try and add (the overnight train), then (a week) and add . In the Multiply tab, look for a in each row. Which rows have one for , and ? For and ? Press the button to reveal the pattern, then check it against Theorems 4 and 5.
The clock laboratory
On a clock with k hours, counting wraps around. Explore adding and multiplying.
9 + 5 = 14 ≡ 2 (mod 12)
14 hours forward on a 12-hour clock lands on 2: the remainder when 14 is divided by 12.
A calendar is a number grid with 7 columns. Every number in one column leaves the same remainder on division by 7. Mark the multiples of 7 and the multiples of 3: which columns do the multiples of 3 visit, and when does the pattern repeat?
A calendar is clock arithmetic
Mark the multiples of a number and look for patterns. Add a second number to find common multiples.
- multiple of 3
- multiple of 7
- common multiple (both)
There are 28 multiples of 3 from 1 to 84.
Common multiples of 3 and 7: 21, 42, 63, 84. The smallest one, 21, is the least common multiple.
Tap a number to see how it is related.
Exercises
1. Clock arithmetic: remainders and modular arithmetic
Warm-upHumanA long-distance bus leaves Nairobi at 17:00 and the journey takes 30 hours. On the 24-hour clock, at what hour does it arrive? (Give a number from 0 to 23.)
2. Clock arithmetic: remainders and modular arithmetic
Warm-upHumanToday is Tuesday. What day of the week will it be in 45 days?
3. Clock arithmetic: remainders and modular arithmetic
CoreHumanWithout multiplying the numbers out, find .
4. Clock arithmetic: remainders and modular arithmetic
CoreHumanWhat is ? (Remember that a remainder modulo is one of .)
5. Clock arithmetic: remainders and modular arithmetic
CoreHumanWhich of these remainders have a multiplicative partner modulo ? (Choose all that apply.)
6. Clock arithmetic: remainders and modular arithmetic
CoreHumanFind the partner of modulo : the number from to with .
7. Clock arithmetic: remainders and modular arithmetic
CoreHumanAmara claims: “If , then or .” For which modulus does a counterexample exist?
8. Clock arithmetic: remainders and modular arithmetic
StretchHumanWhat is the last digit of ?
9. Clock arithmetic: remainders and modular arithmetic
CoreFormalIn Lean, a % n is the remainder of a on division by n. Which statement says that the remainder of a product depends only on the remainders of the factors (Theorem 2)?
10. Clock arithmetic: remainders and modular arithmetic
StretchComputationalWrite a function partners(n) that returns the list of remainders a in range(n) that have a multiplicative partner modulo n — some b in range(n) with a * b % n == 1. Then use it to compare partners(12) with partners(13).
Common misconceptions
Misconception
“Modular arithmetic is only about 12-hour clocks.” Any modulus works: 24 for hours, 7 for weekdays, 10 for last digits, 9 for casting out nines, 11 for book numbers, 60 for minutes and for the Chinese calendar, 2 for even and odd. The 12-hour clock is just the most familiar picture.
Misconception
“If , then or must be .” False in general: , but neither nor is modulo 12. The statement is true when is prime — that is Euclid's lemma.
Misconception
“A remainder can be any number.” A remainder on division by is always one of . So is , not , and is , not . (Some calculators and programming languages give for ; they use a different convention for negative numbers. Python gives .)
Misconception
“Every number has a partner, like fractions.” Only remainders with no common factor with have partners. Modulo 12, has none: is always even, and an even number never leaves remainder on division by .
Other ways of seeing
Algebra— A clock is a group
The hours of a 12-hour clock under addition form a cyclic group of order 12: adding is associative, does nothing, every hour has an opposite that undoes it, and everything is generated by repeatedly adding . The remainders with multiplicative partners form a group under multiplication too: modulo 12 it is , in which every element is its own partner. Modulo a prime , all non-zero remainders form a group, and the integers modulo are a field — a number system in which you can add, subtract, multiply and divide by anything non-zero. See groups and congruences.
Geometry— Turning a regular polygon
Turn a regular 12-sided polygon about its centre by . Turning by and then by is turning by , and a turn by is no turn at all. So the rotations of the polygon are the 12-hour clock: addition modulo is the geometry of rotating a regular -gon. Winding the number line around a circle, as in our picture, is the same idea: every whole number becomes an angle, and numbers differing by a multiple of give the same angle. See symmetry.
Computation— Secrets and fast powers
Computers do arithmetic modulo all the time, because the numbers never grow larger than . Theorem 2 lets a computer find for enormous by repeated squaring, reducing after every step — a few thousand multiplications for a number with hundreds of digits. That fast calculation is the engine of the public-key systems that protect online banking, such as RSA (published in 1977) and Diffie–Hellman key exchange (1976). See cryptography.
Remainder families as sets
Dividing by sorts every whole number — and every integer — into exactly families: the set of numbers with remainder , the set with remainder , and so on up to remainder . Modulo 2 the families are the even and the odd numbers. These sets do not overlap and together they contain every integer: they form a partition. Theorems 1 and 2 say something remarkable about them: if you add a member of one family to a member of another, the family of the answer does not depend on which members you picked. That is why we can add and multiply the families themselves. The Remainder families trail explores this; at university it becomes the idea of an equivalence relation and a quotient (see equivalence relations).
Wonder Trails
History and global context
- China. The Sunzi Suanjing (Master Sun's Mathematical Manual, between the 3rd and 5th centuries CE) asks for a number of things that leaves remainder 2 when counted by threes, 3 when counted by fives and 2 when counted by sevens (answer: 23). In 1247 Qin Jiushao's Mathematical Treatise in Nine Sections gave a general method for such problems, today called the Chinese remainder theorem. Calendar-makers needed exactly this kind of calculation to find when several astronomical cycles line up.
- India. Āryabhaṭa (499 CE) described the kuṭṭaka (“pulveriser”), a method for solving equations such as in whole numbers — in modern terms, finding partners modulo . Brahmagupta (628 CE) and later Indian astronomers refined it.
- Mesoamerica. The Maya combined a 260-day ritual count (13 numbers × 20 day-names) with a 365-day year; the same combination of dates recurs after 18,980 days, about 52 years.
- East Asia. The 60-fold cycle of heavenly stems and earthly branches was used to count days in Shang-dynasty China more than 3000 years ago, and later to name years.
- Europe. Carl Friedrich Gauss introduced the notation and the word modulus in his Disquisitiones Arithmeticae (1801), turning a collection of tricks into a theory.
- East Africa. Swahili timekeeping, counting hours from sunrise, is a living example of shifting a clock by a constant modulo 12.
Further reading
- Joseph H. Silverman, A Friendly Introduction to Number Theory (1997; 4th edition 2012), chapters on congruences — very readable for a strong secondary-school student.
- Øystein Ore, Number Theory and Its History (1948), for the history from Sunzi to Gauss.
- George Gheverghese Joseph, The Crest of the Peacock: Non-European Roots of Mathematics (1991; 3rd edition 2011), on Chinese remainder problems, the Indian kuṭṭaka and Maya calendars.
- Carl Friedrich Gauss, Disquisitiones Arithmeticae (1801; English translation by Arthur A. Clarke, 1966), where congruences began as a theory.