Modular arithmetic has a reputation for being abstract: \mathbb{Z}/n\mathbb{Z}, residue classes, equivalence relations — the vocabulary sounds algebraic. But if you paint each integer by its remainder modulo n and lay the results out on the number line, something vivid happens: the integers arrange themselves into evenly spaced coloured bands. Every number with remainder 0 glows one colour, every number with remainder 1 glows another, and the pattern repeats, stripe by stripe, forever in both directions. The five (or seven, or any n) colour bands you see are the residue classes of \mathbb{Z}/n\mathbb{Z} — the atomic objects of modular arithmetic.

Painting the number line

Fix a modulus n, say n = 5. Go through the integers and, for each one, compute its remainder when divided by 5. The result is a colour: 0 \to red, 1 \to orange, 2 \to yellow, 3 \to green, 4 \to blue (say). Now colour each integer on the number line with its assigned colour. The result looks like a rainbow of evenly spaced stripes, repeating every 5 integers: red-orange-yellow-green-blue, red-orange-yellow-green-blue, forever in both directions.

Two integers have the same colour if and only if they leave the same remainder on division by 5 — that is, if and only if they are congruent modulo 5. So the colour bands are a visualisation of residue classes: each colour = one residue class = one element of \mathbb{Z}/5\mathbb{Z}.

Interactive: change n, watch the bands

Each integer from $-25$ to $25$ gets a colour equal to its remainder mod $n$. Change $n$ with the slider to watch the stripe width change. Set highlight class to $0, 1, \\ldots$ to fade everything except one residue class \u2014 the highlighted dots are $n$ apart, forever.

What the banding reveals

Several facts about \mathbb{Z}/n\mathbb{Z} become immediately visual once you have the colouring.

There are exactly n classes. Count the distinct colours. Whatever n you pick, you get exactly n colours. No more, no less. The set \mathbb{Z}/n\mathbb{Z} has n elements.

Every integer belongs to exactly one class. Every dot on the number line has exactly one colour — there is no integer in two classes, and there is no integer missed. This is the formal statement that residue classes partition \mathbb{Z}.

Same class = same behaviour. All integers of one colour leave the same remainder on division by n. That means they are interchangeable for any purpose that only cares about remainders — adding, multiplying, checking divisibility, finding last digits. Modular arithmetic is the arithmetic you do on colours, not on specific numbers.

Addition moves by a fixed colour shift. Adding a constant k to every integer shifts each colour by k \bmod n positions in the colour cycle. If you paint the original integers and the shifted ones, the stripe patterns are aligned — just shifted. Adding k is a recolouring rule on the whole line.

The period n is exactly the class size

A striking feature: the colour pattern repeats with period exactly n. Not n + 1. Not some smaller period. The block of n consecutive integers starting at any point contains one representative from each residue class.

This is the geometric version of a useful fact: any n consecutive integers are congruent mod n to 0, 1, 2, \ldots, n-1 in some order. So for any problem that asks about "sums of n consecutive integers modulo n" or "products of n consecutive integers modulo n", you can replace them with 0, 1, 2, \ldots, n-1.

A worked example that uses the colouring

Problem: Prove that among any $5$ consecutive integers, exactly one is divisible by $5$

On the n = 5 colour-banded line, an integer is divisible by 5 iff it is coloured red (remainder 0). The colour pattern cycles with period 5: red-orange-yellow-green-blue-red-orange-…

Any block of 5 consecutive integers is exactly one "full stripe" of the pattern. So it contains exactly one red dot — exactly one multiple of 5.

Why: the colours within any 5 consecutive positions are a permutation of {red, orange, yellow, green, blue}. Each colour appears once. In particular, red appears once.

This is a one-sentence proof once the visualisation is internalised. Without the picture, you would write a case-by-case argument. With the picture, it is obvious.

Why bands, not dots, capture the "class" idea

The word class in "residue class" suggests a collection, not a single number. The colour-banding makes that collection visible: the red class of mod-5 is not the number 0 — it is the entire set \{\ldots, -10, -5, 0, 5, 10, 15, \ldots\}, all drawn in red. When a problem says "let [a] \in \mathbb{Z}/n\mathbb{Z}", it means: pick the colour of a. The specific integer you choose as a representative doesn't matter, because everyone in the colour band behaves the same way modulo n.

Connection to divisibility rules

The banding also makes divisibility rules visual. "A number is divisible by 3 iff the sum of its digits is divisible by 3" becomes: on the mod-3 colouring, numbers with digit-sums in the same colour class end up with themselves in the same colour class. The bands carry the information.

More subtly, the banding explains why the "last digit" rule works for mod 10: on the mod-10 colour pattern, the last digit of an integer is its colour. That is why you only need the last digit to find N \bmod 10.

Why this picture is hard to un-see

Once you imagine the integers as a rainbow of stripes repeating with period n, a lot of modular-arithmetic jargon becomes natural. Congruence? Same colour. Residue class? A stripe. \mathbb{Z}/n\mathbb{Z}? The set of n colours. The addition and multiplication tables of \mathbb{Z}/n\mathbb{Z}? Rules for what colour you get when you combine two colours. The picture does not replace the algebra — but it makes every definition point to something tangible, and the tangible thing is stripes on a line.

The one-line takeaway

Paint each integer by its remainder mod n, and the number line becomes a repeating stripe pattern of exactly n colours. Each stripe is a residue class; same colour means congruent mod n.

Related: Modular Arithmetic · Number Line Wrapping into a Circle · Chinese Remainder Theorem — Two Clocks Visualiser · Number Theory Basics · Relations