Visual walkthrough — Rational numbers — definition, decimal expansion (terminating - repeating)
We build everything from the Long division algorithm and a single counting idea. The end results live in the parent note Rational Numbers 2.5.3; here we earn them picture by picture.
Step 1 — What long division actually does to a fraction
WHAT. Let me define the whole machine before using any symbol.
- = the numerator, the number on top (how many pieces we start with).
- = the denominator, the number on the bottom, and (you cannot split into zero groups).
- A remainder = what is left over after you take out as many whole groups of as you can. If you split into groups of , you get whole groups and left over — remainder .
Long division of by works like this, one digit at a time:
- Take the current remainder .
- Stick a on its end — that is the same as computing . (Sticking a zero on a number multiplies it by ten: .)
- See how many times fits into . That count is the next decimal digit.
- Whatever is left over is the new remainder. Repeat.
WHY. We multiply by each step because our writing system is base ten — each place to the right is worth ten times less. Long division is just "carry the leftover into the next tenths place."
PICTURE. The conveyor belt below: a remainder goes in, gets a zero glued on (), is divided by to spit out one digit, and leaves a new remainder that loops back to the front.

Step 2 — The remainder can only be one of finitely many numbers
WHAT. After you divide by , the leftover is always smaller than . Why? If the leftover were or bigger, you could have fit one more group of in — so you didn't finish dividing. So every remainder is forced into the set That is exactly different boxes it could land in — no more.
WHY. This is the whole trick of the proof. We are not looking at the digits (there could be infinitely many). We are looking at the remainders, and there are only finitely many of them. Counting the boxes is what makes the argument work.
PICTURE. Below, a row of exactly pigeonholes labelled through . Every step of long division must drop its remainder into one of these boxes — there is nowhere else to go.

Step 3 — Case A: a remainder hits zero → the decimal STOPS
WHAT. Look at the recipe . Suppose at some step . Then next step we glue a zero on to get , divide by to get digit , remainder again... forever zeros. We just stop writing them.
WHY. A remainder of means the division came out exact — nothing is left over. That is precisely what a terminating decimal is.
PICTURE. The belt for below. Remainder . The moment it lands in the box, the machine halts.

Step 4 — Case B: no zero ever → a remainder MUST repeat (pigeonhole)
WHAT. Now suppose never shows up. Then every remainder lives in the smaller set — that's only boxes. But long division keeps producing remainders forever: remainder #1, #2, #3, ... an endless list. If you place infinitely many things into boxes, two of them must land in the same box. That is the Pigeonhole Principle: more pigeons than holes ⇒ some hole holds two.
WHY. Here is the killer link. The recipe depends only on . So the same remainder always produces the same next digit and the same next remainder. The instant a remainder repeats, the entire future repeats — the decimal loops.
PICTURE. Below: . Remainders go . Once the second appears (a repeat), the arrow bites its own tail — a loop — and digit repeats forever.

Recall Why does the whole pattern repeat, not just one digit?
Because the next digit and next remainder are a function of the current remainder alone ::: same input ⇒ same output ⇒ same everything from that point on.
Step 5 — How LONG is the loop? (the pigeonhole gives a bound)
WHAT. Because there are at most non-zero boxes, a remainder must repeat within at most steps. So the repeating block (the repetend) is at most digits long.
WHY. We are just counting: you cannot walk through more than distinct non-zero boxes before you are forced to revisit one.
PICTURE. below walks a full cyclic tour — visiting all non-zero boxes exactly once before returning home.

The sharper truth — that the exact length divides , the Euler's totient function — comes from Modular arithmetic (the repetend length is the order of mod ). The pigeonhole here only promises ""; it does not promise "."
Step 6 — Which case do you get? The prime-factor test
WHAT. So when does zero appear (Case A) versus never (Case B)? Answer, using Prime factorization of in lowest terms:
WHY. A decimal that stops after places is for some integer . Since has only the primes and , and the fraction is in lowest terms, must divide — so can carry only 's and 's. Any stray prime like or can never divide a power of ten, so zero never comes and the decimal is forced to loop.
PICTURE. The sorting gate below: the prime factors of pour in; if only 's and 's pass, it drops into the STOP bin, otherwise into the LOOP bin.

Step 7 — The degenerate corners (never leave a gap)
WHAT & WHY & PICTURE — the easy-to-forget edges:
- : . Remainder is from the start — instant terminate. Zero belongs to both camps (it terminates).
- : , a whole number, decimal — terminates. Every integer is a terminating "decimal."
- : forbidden. There is no "how many groups of nothing" — the machine has no first step. This is why the definition bans it.
- The trap: a repeating is a disguised terminator: . (Multiply by : , subtract: , .) Case A and Case B touch here — two names for one number.

Recall Convert
back to a fraction (the reverse machine) Let ; multiply by : ; subtract: ::: .
The one-picture summary
Everything on one board: the belt runs, remainders drop into boxes; either a box is (STOP) or the pigeonhole forces a repeat (LOOP). The prime factors of decide which door. There is no third door — no "wander forever with no pattern." That third door is where the Irrational numbers live, outside Real numbers that are rational.

Recall Feynman retelling — say it like you're teaching a friend
When you long-divide by , at each step you just carry the leftover, glue a zero on it, and divide again. The leftover — the remainder — is always smaller than , so there are only possible leftovers: boxes through . Run the machine forever and only two things can happen. One: you hit the leftover , the division comes out exact, and the decimal stops — that's a terminating decimal, and it happens exactly when is built only from s and s (because ). Two: you never hit , but since there are only finitely many boxes and infinitely many steps, some leftover must come back around — and because the next digit depends only on the current leftover, the whole pattern repeats from there. That's a repeating decimal. The loop can't be longer than (you'd run out of boxes). And a never-repeating, never-stopping decimal? Impossible for a fraction — that's reserved for irrational numbers. Stop, loop, nothing else.