Labs / Mathematics
Modular Arithmetic
The numbers 0 to m − 1 sit on a circular clock. Press play and the hand hops around by k each tick — adding or multiplying — drawing chords that trace the pattern of the operation. Tap any number to start the walk somewhere new, and drag the sliders to change the modulus and the step.
step 0residue 0cycle 12/12gcd 1 ✓ all
What to try
- With m = 12, which values of k eventually visit every number on the clock, and which get stuck in a short loop?
- The readout shows gcd(k, m). What do all the k that reach every number have in common with m?
- Switch to “Multiply k”. Why does the pattern suddenly look like a flower or a cardioid instead of an even star?
- Set m to a prime like 7 or 13. Does that make it easier or harder to find a k that hits everything?
- Multiply by k when k shares a factor with m — where does the pointer get trapped, and can it ever return to where it started?