Repeating Decimals

Here's something a bit random for Friday. (Presumably this actually is quite well-known; but having never taken a course in number theory...)

Question: Given a fraction m/n in lowest terms, and expand it in "decimal notation" in a number base b. What are the conditions on m, n, and b that guarantees that the expansion eventually consists of a single repeating "digit"? (Note, we can clearly assume 0 < m < n.)

To make the question more clear, let's look at some examples in base b = 10. Obviously, if n = 1, then the fraction is in fact integral, and its expansion is $m.\dot{0}$ has a repeated digit 0. If n = 2, the decimal expansion is either $0.\dot0$ or $0.5\dot{0}$. Similarly n = 4, 5, 8, 10 all have terminating decimals, so repeats the digit 0 eventually. n = 3,6,9 on the other hand, will lead to repeating digits other than 0, whereas n = 7 will lead to a repetition of a string of the 6 digits ...142857142857...

Here's the solution. Suppose m/n has an expansion of the prescribed form. Recall that a "decimal expansion" $0.a_1a_2a_3a_4\ldots$ in base $b$ is in fact a short hand for \[ 0 + \frac{a_1}{b} + \frac{a_2}{b^2} + \frac{a_3}{b^3} \ldots\] So the criterion specified in the question is equivalent to the condition that

There exists some integer K, a number $c < b^K$, and a digit d such that \[ \frac{m}{n} = \frac{c}{b^K} + \frac{d}{b^K} \sum_{j = 1}^{\infty} \frac{1}{b^j}\] which corresponds to the decimal expansion \[ 0.\underbrace{XXXXXXXXXXXX}_{\text{the digits given by }c} ddddddddddd\ldots\]

The infinite sum on the far right can be solved: $\sum_1^\infty b^{-j} = (b-1)^{-1}$. Multiplying the expression through by $b^K$ we have \[ \frac{m b^K}{n} = c + \frac{d}{b-1}\] Now, by redefining $c \to c\cdot b^k + d \sum_1^{k-1} b^j$, we can replace $K\to K+k$. So we can set $K$ arbitrarily large. Which means that by doing so, after setting the left hand side to lowest terms, we can "remove" from n any prime factors that also divides $b$. To be more precise: suppose $p$ is a prime such that $p^\ell | n$ and $p^{\ell+1}$ does not divide $n$. (So that p goes into n exactly $\ell$ times.) Now suppose $p|b$ also, then the fraction $b^\ell / n$, when written in lowest terms, has a denominator that cannot be divided by $p$. Repeating this for all common prime factors of n and b we can get rid of all common prime factors from the denominator. Let us denote by $n_0$ the number $ n$ with all the prime divisors of $b$ removed.

Our equation then implies that there exists some integer $m'$ that is coprime with $n_0$ such that \[\frac{m'}{n_0} = \frac{d}{b-1}\] which means that $n_0$ must divide $(b-1)$. That is

Answer: Let $n_0$ be the number $n$ with all prime divisors of $b$ removed. Then $n_0$ must divide $(b-1)$.

For base b = 10, (b-1) = 9. This means that any n for which the decimal expansion is eventually repeating with period 1 must have the form $n = 2^s\cdot 5^t\cdot 3^r$ where $s,t$ are non-negative integers, and $r$ is one of 0, 1, or 2.

Avatar
Willie WY Wong
Assistant Professor

My research interests include partial differential equations, geometric analysis, fluid dynamics, and general relativity.

Related