#>arithmetic_with_memory
primes congruence divisibility

Math · Toy-First Monograph

Count by 4 on a 12-hour clock and you trap a triangle; count by 5 and you weave a star.

Throw away full turns and keep only the remainder: suddenly plain integers grow grain, bottlenecks, and hidden symmetry. Drag the modular clock right below from composite 12 to prime 13 before reading a single definition — watch shared factors collapse into spokes while coprimes touch every hour.

Two red eyes and a dark spike over a page of calendar numbers, with a column of labeled practices from logistics to production
Calendar residues · on the shelf A calendar page is already a residue lattice: numbers falling into repeating weeks, close to the modular clock and the jump into prime fields.
^"modular_clock"{

Try the clock first: i ↦ k × i (mod n)

~#expect before you drag: keep modulus at 12 and slide multiplier from 5 to 6 — predict how many hours survive on the rim. Then slide modulus to 13 and try to make any multiplier collapse. You cannot: prime moduli have no shared divisors to fold along, which is the whole doorway into finite fields and parser equivalence classes.

Modular multiplication clock A modular arithmetic clock diagram that updates when the modulus and multiplier controls move.
Default state (scripts off): multiplication by 5 on a 12-hour clock — coprime stride, zero collapsed spokes.

Move the controls to compare prime and composite moduli.

.intuition_first

Why forgetting full turns reveals hidden grain

Real-number division smooths everything out (14 ÷ 12 = 1.166…). Integer arithmetic refuses to forget the remainder (14 ≡ 2 mod 12). That productive act of throwing away full turns turns an infinite line into a finite wheel where prime bottlenecks, cyclic orbits, and shared factors become visible geometry.

Prime bottlenecks

Primes cannot be factored into smaller steps, so on a prime clock every non-zero multiplier permutes all hours cleanly without collisions.

anchor: divisibility handles

Visible folding

When gcd(k, n) = d > 1, the wheel folds d-to-1 onto a smaller sub-polygon — divisibility drawn as chord density.

anchor: modular clock

Field bridge

Because prime wheels never fold to zero, every non-zero residue has a multiplicative inverse — turning clock arithmetic into a full field.

next: prime fields
~"visual_handles"

Divisibility Handles

?prime

Prime

A prime is a number with no nontrivial divisors. In number theory, primes often mark the points where arithmetic becomes cleaner or more rigid.

field theory anchor: prime fields
~gcd

Greatest Common Divisor

The gcd tells you how much two numbers overlap structurally. In the modular clock, it controls whether the pattern permutes or collapses.

anchor: modular clock
^residue

Residue Class

Residues are arithmetic positions remembered after full turns are forgotten. They are the central visual objects in modular arithmetic.

category anchor: composition square
&euclid

Euclidean Habit

The Euclidean algorithm is a way of thinking, not only a procedure: keep dividing, keep tracking remainders, and structure eventually appears.

complexity anchor: growth intuition
&["neighbor_routes"]

Neighbor Routes

Field Theory

Finite fields often begin with modular arithmetic modulo a prime. Number theory supplies the raw material that field theory organizes.

route: Prime fields

Combinatorics

Residue classes, partitions, and finite counting arguments often overlap, especially when periodicity or recurrence matters.

route: Combinatorics intuition

Category Theory

Category language can make arithmetic feel less isolated by treating operations and preserved structure as first-class relationships.

route: Category insight

Parsers

Even bespoke parser design benefits from number-theoretic habits: small generators, repeating states, and residue-like equivalence classes.

route: Parser doodles