Modular Arithmetic — The Number Wheel & Fast Exponentiation

Reduce every value mod m onto a wheel of m slots. Watch a+b and a×b wrap past 0, see negatives count backward, and trace ab mod m by square-and-multiply.

step 0

Number wheel (mod m)

Press Step to begin.
a b result

Modular exponentiation trace (ab mod m)

Modular arithmetic keeps every number in [0, m). Choose a mode above and step through it. Negative results normalize with ((x % m) + m) % m.
Self-contained visualization. The wheel has m slots 0..m−1; addition and multiplication wrap past 0, and −a counts backward to land in [0, m). The right panel runs square-and-multiply for ab mod m. See junior.md and middle.md for the safe patterns and professional.md for why Z/mZ is a ring (and a field when m is prime).