Modular Arithmetic in Puzzles
A toolkit of remainder-based shortcuts — working with what's left over after division — that turns brainteaser questions about cycles, patterns, and divisibility into a couple of lines of arithmetic.
Modular arithmetic asks only about the remainder left after dividing by some fixed number, called the modulus, and interview puzzles frequently collapse into a one-line remainder calculation once you spot the cycle. Writing "" just means and leave the same remainder when divided by — for instance , since both leave remainder 2.
A common puzzle type: "if today is Wednesday, what day of the week is it in 100 days?" Since the week cycles every 7 days, only the remainder of 100 divided by 7 matters: , so the remainder is 2, meaning 2 days after Wednesday — Friday. The trick generalizes to any cyclic pattern: clock hours (mod 12), a repeating digit pattern in a large power (e.g., the last digit of cycles through 7, 9, 3, 1 every 4 powers, so check , landing on the 4th element of the cycle, which is 1), or a sequence of coin flips that repeats every steps.
The general move in any such puzzle is the same three steps: identify the cycle length, reduce the target number modulo that length, and read off the corresponding position in one cycle — turning what looks like a huge computation into simple division with a remainder.
Whenever a puzzle involves something that repeats in a fixed cycle, the answer only depends on the target number's remainder modulo the cycle length — reduce first, then read off the position in a single cycle.
Related concepts
Practice in interviews
Further reading
- Engel, Problem-Solving Strategies, ch. on number theory