Repeating Decimals

Type a fraction, then change the base. In base 10, 1/3 runs forever and 1/5 stops. In base 12 they swap places. The rule behind that is exact, and it is about prime factors.

Loading interactive simulation...

One third is tidy in base twelve 🖖

Press 1/3 in base 10, then 1/3 in base 12. Same fraction. In one it runs forever; in the other it is 0.4 and finished. Press 1/5 in base 12 and the two trade places. So whether a fraction is "tidy" has nothing to do with the fraction. p/q, in lowest terms, stops in base b exactly when every prime factor of q also divides b. Ten is 2 x 5, so the only denominators that can ever stop are the ones built from 2s and 5s: halves, quarters, fifths, eighths, tenths, twentieths, and anything else made from those two primes. You already know that list. It is the one you were made to memorise.

Two primes, two different jobs 🖖

One sixth is 0.1666…: one digit that never comes back, then a 6 forever. Six is 2 x 3, and the two primes are doing different work. The 2 divides ten and gives you the head. The 3 does not, and gives you the tail. Now try 7/12. The head is two digits long, because twelve carries two 2s and the division needs two steps to use them up. So the head is not as long as the number of shared primes; it is as long as it takes to exhaust them. In base 10 that makes 1/8 three digits. In base 12 it makes it two.

Why 1/7 is the same six digits over and over 🖖

Dividing by 7 leaves only six possible non-zero remainders. Six steps in, one of them has to come round again, and from there the digits have no choice but to repeat. That is what the ring above is: every remainder the division could possibly meet, and the cycle can never be longer than q − 1. Sevenths fill it: the walk visits all six remainders before it gets home, which is where 142857 gets its party trick. Try 1/13 and half the ring stays hollow instead, six of twelve, giving 076923. Because the division passes through every remainder on the way, starting at 2 rather than 1 just drops you further round the same loop. 2/7 = 0.285714. 3/7 = 0.428571. The same six digits, rotated. Under 100, nine of the twenty-three eligible primes manage this in base 10: 7, 17, 19, 23, 29, 47, 59, 61 and 97. Base 12 has eight, and only 7 and 17 are on both lists.

Problems solved in full

  1. The number of digits 1/13 repeats for 7 steps

    How many digits does 1/13 repeat for? You can answer that before dividing anything.

    1. Does it repeat at all? Thirteen is prime and does not divide ten, so it shares no factor with the base. Nothing divides out, so there is no head and the repeat starts at the first digit.

    2. The length is the smallest power of ten that leaves remainder 1. Walk up the powers of ten modulo 13 and stop the moment you hit it.

    3. Six. The cycle is six digits long and we have divided nothing. Now do the division, and watch those same six numbers come back as the remainders.

    4. They are the same numbers in the same order, because that is what they are: the remainder after k steps is 10 to the k, modulo 13. The digits sitting above them are the answer.

    5. The old check still works. A pure repeating block of length six, times its denominator, gives six nines.

    6. Thirteen had twelve remainders available and used six. Not any six, though. For a prime q the period always divides q − 1, so the only possible answers for 13 were 1, 2, 3, 4, 6 and 12.

    7. Which of those divisors a prime lands on is where this tool runs out, and so does everyone else. Nine of the twenty-three eligible primes under 100 reach the full q − 1 in base 10, about 39%, close to the constant 0.3739 that Artin conjectured in 1927. It is still a conjecture. Nobody has managed to prove even that infinitely many primes have 10 as a primitive root.

    Answer

    Six digits: 1/13 = 0.076923 repeating. Read off the powers of ten before any division happened. And 13 misses the maximum, because 6 is only half of 12.

  2. Why one fifth stops in base ten and runs for ever in base twelve 6 steps

    Load 1/5 in base 12 and work out how long the repeat runs. Then decide whether a world that counted in twelves would be better or worse off at ordinary arithmetic.

    1. In base ten one fifth is the easiest fraction there is: 0.2, finished in a single digit. Twelve is 2 × 2 × 3 and has no five in it, so nothing divides out and the long division can never run out of remainder. The verdict card flips to Repeats forever and the head reads 0. There is no terminating part to get through first, so the cycle starts at the very first digit.

    2. The length is the smallest power of twelve that leaves a remainder of 1 when divided by 5. Twelve is two more than a multiple of five, so you can walk the powers of two instead, which is quicker: 2, 4, 3, 1.

    3. Four steps, and four is q − 1. That is as long as a fifth can possibly repeat, because long division has only four non-zero remainders available and this walk visits every one of them. The badge that appears is the one 1/7 earns in base ten.

    4. The nines check survives the move. A pure cycle multiplied by its denominator fills every place of the cycle: 2497 in base twelve is 4,147, five of those is 20,735, and 20,735 is 12⁴ − 1, which base twelve writes as bbbb. Four elevens where base ten would give four nines.

    5. Now the trade, counted rather than argued about. Take the denominators 2 to 12 and ask which of them stop. Binary and hexadecimal manage three, since their only prime is 2. That is the reason 0.1 has no exact binary form and the reason money is not kept in floating point. Base ten manages five. Base twelve manages seven: it buys thirds, sixths, ninths and twelfths, and pays for them with fifths and tenths.

    6. The rule also settles a base the tool does not offer. Sixty carries all three of the small primes, so everything from 2 to 12 stops except sevenths and elevenths, nine of the eleven. Nothing has to be run to see it. It takes the prime factors of sixty and no more.

    Answer

    Four digits, 0.2497 repeating, and the longest cycle a fifth can have. Base twelve wins the count seven to five, and it wins the divisions people actually make: a third of an hour, a sixth of a circle, a quarter of a pound. What it gives up is fifths and tenths, and those matter mostly because we already count in tens. A fifth feels fundamental because it is 20%, and percentages are a decimal habit rather than a fact about fifths.

    The honest limit is that no base rescues sevenths, and a seventh turns up in ordinary life about as often as a fifth does. Whichever base you pick, some everyday division comes out ragged, which is why counting the winners settles nothing. The one place a choice was made and held is Babylon's sixty. Four thousand years later it is still how you read a clock and still how a circle is divided.

Learning path

Writing a number down

Leads to Rational approximation a number you cannot finish writing.

References (3)
  • The rule the tool implements: when a fraction terminates, and the period as the order of the base Hardy, G. H. and Wright, E. M. (2008). An Introduction to the Theory of Numbers (6th ed.). Oxford University Press — Chapter IX, Decimals.
  • Artin's constant 0.3739558, the density the worked problem compares 9 of 23 against Wrench, J. W. (1961). Evaluation of Artin's Constant and the Twin-Prime Constant. Mathematics of Computation, 15(76), 396–398. doi:10.1090/S0025-5718-1961-0124305-0
  • Why the worked problem ends by saying nobody has proved it Heath-Brown, D. R. (1986). Artin's Conjecture for Primitive Roots. The Quarterly Journal of Mathematics, 37(1), 27–38. doi:10.1093/qmath/37.1.27

Example problems

  • 1/3 in base 10 - One third repeats from the first digit: 0 digits before the repeat, then a cycle of 1. Ten is 2 x 5, and 3 divides neither of them.
  • 1/3 in base 12 - The same fraction in base 12 is 0.4, and it stops. Nothing about one third has changed. Twelve is 2 x 2 x 3, so the 3 divides out.
  • 1/5 in base 12 - One fifth does the reverse. It stops in base 10; here it repeats, with a cycle of 4. That is the longest a fifth could manage.
  • 1/6 — both at once - One sixth does both things. Six is 2 x 3: the 2 divides ten and gives 1 digit that never repeats, then the 3 takes over with a cycle of 1.
  • 1/7 — the famous one - A cycle of 6 for a denominator of 7 is as long as a seventh can possibly be. Long division has only 6 non-zero remainders to visit before one comes round again.
  • 1/17 — sixteen digits - Sixteen digits, and again the maximum. The walk below visits all 16 available remainders before it returns to where it started.