A logbook for curious waters
← All Reckonings

The Daily Reckoning

Why Does a Repeating Decimal Always Hide a Fraction?

A repeating decimal is a long-division machine revisiting an old remainder. That loop proves the number is an exact fraction, not an approximation.

Difficulty
Foundational
Area
Numbers and algebra
Reading time
9 minutes
Prerequisites
Fractions and long division · Multiplication by powers of ten · Solving a one-step equation
A dark maritime blueprint shows a luminous chain of decimal-place compartments curling back into a closed cyan loop, with acid-green pulses repeating around the circuit and a magenta division grid beneath it.

Divide 11 by 77 and the decimal refuses to end:

17=0.142857142857…\frac17=0.142857142857\ldots

The six digits 142857142857 return in the same order forever. The repetition is not a coincidence in the digits. Long division has returned to a remainder it has seen before. Once the same remainder returns, every later decision repeats too.

The interactive remainder machine makes that loop visible. Start with 1/71/7, then compare it with a fraction that has a shorter loop and one whose decimal terminates. Each card records one exact long-division step.

Long division, one state at a time

Follow the remainder

1/7 = 0.142857…

current remainder= denominator × next digit + next remainder

    What to notice: a repeated remainder creates a loop because it forces the same next digit and next remainder. Remainder zero ends the process. The cards use words, equations, and borders as well as color.

    The claim in precise form

    A rational number is a number that can be written as

    pq,\frac pq,

    where pp and qq are integers and q≠0q\ne0.

    A decimal is eventually periodic when some finite block of digits repeats forever after a possible nonrepeating beginning. For example,

    0.123‾=0.123333…0.12\overline{3}=0.123333\ldots

    has the nonrepeating beginning 1212 and the repeating block 33. A terminating decimal counts as eventually periodic if zeros are appended forever: 0.125=0.125000…0.125=0.125000\ldots.

    The central theorem is an exact two-way statement:

    A real number is rational if and only if its decimal expansion terminates or eventually repeats.

    The two directions need different explanations. Long division proves that fractions must loop. Multiplication by a power of ten followed by subtraction turns any repeating decimal back into a fraction.

    Why a fraction must terminate or repeat

    Suppose 0<p<q0<p<q and we calculate p/qp/q by long division. At every step, the current remainder is one of

    0,1,2,…,q−1.0,1,2,\ldots,q-1.

    There are only qq possible remainders.

    For 1/71/7, the first step multiplies the remainder 11 by 1010:

    10=7(1)+3.10=7(1)+3.

    The quotient digit is 11, and the next remainder is 33. The next step is

    30=7(4)+2,30=7(4)+2,

    so the next digit is 44 and the next remainder is 22. Continuing gives the remainder path

    1→3→2→6→4→5→1.1\to3\to2\to6\to4\to5\to1.

    The path has returned to remainder 11. The same input to long division produces the same quotient digit and the same next remainder, so the six-digit cycle starts again.

    The general argument is just as tight. If a remainder becomes 00, the decimal terminates. If no remainder becomes 00, long division keeps choosing from the finite list 1,2,…,q−11,2,\ldots,q-1. Eventually one remainder must recur. From that recurrence onward, the digits repeat.

    This is the pigeonhole principle inside long division: an endless process with only finitely many possible states must revisit a state.

    Worked example: turn a mixed decimal into a fraction

    Let

    x=0.123‾=0.123333…x=0.12\overline{3}=0.123333\ldots

    The repeating block begins after two decimal places and contains one digit. First multiply by 100100 to move the nonrepeating beginning left of the decimal point:

    100x=12.3333…100x=12.3333\ldots

    Now multiply the original number by 10001000. This moves one additional digit—the entire repeating block—left of the decimal point:

    1000x=123.3333…1000x=123.3333\ldots

    The infinite tails are now identical. Subtract the first shifted equation from the second:

    1000x−100x=123.3333…−12.3333…900x=111.\begin{aligned} 1000x-100x&=123.3333\ldots-12.3333\ldots\\ 900x&=111. \end{aligned}

    Divide both sides by 900900:

    x=111900=37300.x=\frac{111}{900}=\frac{37}{300}.

    No infinite approximation remains. The repeating decimal is exactly 37/30037/300.

    The same calculation gives a reusable formula. Suppose a decimal has mm nonrepeating digits followed by a repeating block of nn digits. Let N1N_1 be the integer formed by the first m+nm+n digits, and let N0N_0 be the integer formed by the first mm digits. Then

    x=N1−N010m+n−10m.x=\frac{N_1-N_0}{10^{m+n}-10^m}.

    For 0.123‾0.12\overline3, we have m=2m=2, n=1n=1, N1=123N_1=123, and N0=12N_0=12, so

    x=123−12103−102=111900.x=\frac{123-12}{10^3-10^2}=\frac{111}{900}.

    A pure repeating block has a denominator made of nines

    When repetition begins immediately after the decimal point, m=0m=0. A block of nn digits represents an integer BB, and the formula becomes

    0.B‾=B10n−1.0.\overline{B}=\frac{B}{10^n-1}.

    The denominator 10n−110^n-1 is a row of nn nines. Therefore

    0.27‾=2799=3110.\overline{27}=\frac{27}{99}=\frac3{11}

    and

    0.045‾=45999=5111.0.\overline{045}=\frac{45}{999}=\frac5{111}.

    The leading zero in the block 045045 matters because the period contains three positions, so the first denominator is 999999, not 9999.

    This calculation also settles the famous edge case:

    0.9‾=99=1.0.\overline9=\frac99=1.

    The symbols 0.999…0.999\ldots and 1.000…1.000\ldots are two decimal representations of the same real number. There is no positive gap between them waiting beyond every finite decimal place.

    The idea developed across several mathematical cultures

    Decimal fractions were not produced by one isolated inventor. Positional calculation grew through Indian arithmetic and its transmission and development in the Islamic world. MacTutor identifies a tenth-century text by Abu’l-Hasan al-Uqlidisi as the earliest known direct treatment of decimal fractions. Al-Uqlidisi wrote for working arithmetic, including calculations performed without a dust board, so the notation belonged to practical computation as well as theory.

    In the fifteenth century, the astronomer and mathematician Jamshid al-Kashi gave a systematic account of decimal fractions and used them in high-precision numerical work. Astronomy, surveying, commerce, and measurement all rewarded notation that made fractional calculation behave more like whole-number calculation.

    Simon Stevin’s short 1585 book De Thiende—The Tenth—helped make decimal fractions widely usable in Europe. Stevin advocated decimal arithmetic for measurement, money, and everyday calculation. That influence once led European histories to credit Stevin with invention; later scholarship restored the much earlier work of al-Uqlidisi, al-Kashi, and other mathematicians. MacTutor’s history of fraction notation and the Mathematical Association of America’s account of research on Islamic mathematics trace that correction.

    Where the loop matters now

    The theorem distinguishes a number from the notation used to store it. The fraction 1/101/10 terminates in base ten, but its binary expansion repeats. Most computer hardware therefore stores the nearest available binary floating-point value rather than 1/101/10 itself. The official Python floating-point tutorial uses 0.10.1 to explain why a displayed decimal can hide a nearby binary fraction and why small rounding effects are inherent in binary floating-point arithmetic.

    Programs that require exact ratios can store a numerator and denominator instead. Python’s fractions module implements that approach. Programs that need familiar base-ten rounding rules—for example, some financial calculations—can use decimal arithmetic with an explicit precision and rounding policy. The choice of representation is part of the mathematics of the program, not a formatting detail.

    The length of a repeating block also comes from remainder arithmetic. The six-step loop for 1/71/7 is a cycle of powers of 1010 modulo 77. That connection leads directly to modular arithmetic, full-reptend primes, and divisibility tests. The earlier Reckoning How Can 7²²² Fit on a Clock? develops the same remainder arithmetic from a different direction.

    Try two

    Problem 1: Convert 0.045‾0.\overline{045} to a fraction in lowest terms.

    The repeating block has three digits, so multiply by 10001000:

    x=0.045045…,1000x=45.045045…x=0.045045\ldots, \qquad 1000x=45.045045\ldots

    Subtract the first equation from the second:

    999x=45.999x=45.

    Therefore

    x=45999.x=\frac{45}{999}.

    Both numerator and denominator are divisible by 99:

    45999=5111.\frac{45}{999}=\frac5{111}.
    Problem 2: Show that 0.583‾0.58\overline3 is exactly 7/127/12.

    There are two nonrepeating digits and one repeating digit. Let

    x=0.583333…x=0.583333\ldots

    Then

    100x=58.3333…100x=58.3333\ldots

    and

    1000x=583.3333…1000x=583.3333\ldots

    Subtract:

    900x=525.900x=525.

    Thus

    x=525900=712.x=\frac{525}{900}=\frac7{12}.

    Long division checks the result: 7/12=0.583333…7/12=0.583333\ldots because the remainder becomes 44 after the second digit and then stays 44, producing another 33 at every later step.

    The idea to keep

    A repeating decimal is finite-state arithmetic in disguise. A fraction’s long division can use only finitely many remainders, so it must stop or revisit one; a repeated digit block can be shifted and subtracted, leaving an exact ratio of integers.

    Continue with modular arithmetic to study remainder cycles directly, or with geometric series to reach the same fractions by adding an infinite sequence of shrinking terms.

    Sources