# How can I prove that all rational numbers are either terminating decimal or repeating decimal numerals?

I am trying to figure out how to prove that all rational numbers are either terminating decimal or repeating decimal numerals, but I am having a great difficulty in doing so. Any help will be greatly appreciated.

Recall that in long division, one gets a remainder at each step: $$\begin{array} & & & 0 & . & 2 & 2 & 7 & 2 \\ \hline 22 & ) & 5&.&0&0&0&0&0 \\ & & 4 & & 4 \\ & & & & 6 & 0 & \leftarrow \\ & & & & 4 & 4 \\ & & & & 1 & 6 & 0 \\ & & & & 1 & 5 & 4 \\ & & & & & & 6 & 0 & \leftarrow & \text{repeating}\\ \end{array}$$ 6 is a remainder. The next remainder is 16. Then the next is 6. This brings us back to where we were at an earlier step: Dividing 60 by 22. We have to get the same answer we got the previous time. Hence we have repetition of "27". The answer is $0.2272727\overline{27}\ldots$, where "27" keeps repeating.

The question then is: Why must we always return to a remainder that we saw earlier? The answer is that the only possible remainders are $0, 1, 2, 3, \ldots, 21$ (if $22$ is what we're dividing by) and there are only finitely many. If we get 0, the process terminates. If we never get 0, we have only 21 possibilities, so we can go at most 21 steps without seeing one that we've seen before. As soon as we get one that we've seen before, the repetition begins.

A related question worth asking is how you know that every repeating decimal corresponds to a rational number. E.g., if you're handed $0.2272727\overline{27}\ldots$ with "27" repeating forever, how do you figure out that it's exactly $5/22$? There's a simple algorithm for that too.

Hint$$\$$ Consider what it means for a real $$\rm\ 0 < \alpha < 1\$$ to have a periodic decimal expansion:

$$\begin{array}{rrl} &\alpha\!\!\! &\rm =\,\ 0\:.\overbrace{a_1a_2\cdots a_n^{\phantom{l}}}^{\textstyle a}\ \overbrace{\overline{c_1c_2\cdots c_k}}^{\textstyle \overline c}\ \ \text{ in radix } 10\\[.2em] \iff& \beta \!\!&\!:= \rm 10^n\, \alpha\! -\! a = 0\:.\overline{c_1c_2\cdots c_k}\\[.2em] \iff& 10^k\: \beta \!\!&=\ \rm c + \beta\\[.2em] \iff& (10^k-1)\ \beta \!\!&=\ \rm c\\[.2em] \iff&\!\!\!\! \rm (10^k-1)\ 10^n\: \alpha \!\!&\in\ \Bbb Z \end{array}\qquad$$

Thus to show that a rational $$\rm\,\alpha\,$$ has such a periodic expansion, it suffices to find $$\rm\,k,n\,$$ as above, i.e. so that $$\rm\,(10^k-1)\,10^n\,$$ serves as a denominator for $$\rm\,\alpha.\,$$ Put $$\rm\,\alpha\, = a/b,\,$$ and $$\rm\, b = 2^i\,5^j\,d,\,$$ where $$\rm\,2,5\,\nmid d\,.\,$$ Choosing $$\rm\,n\, >\, i,\,j\,$$ ensures that $$\rm\,10^n\,\alpha\,$$ has no factors of $$\rm\,2\,$$ or $$\rm\,5\,$$ in its denominator. Hence it remains to find some $$\rm\,k\,$$ such that $$\rm\,10^k-1\,$$ will cancel the remaining factor of $$\rm\,d\,$$ in the denominator, i.e. such that $$\rm\,d\,|\,10^k-1\,,\,$$ or $$\rm\,10^k\equiv 1\pmod{d}\,.\,$$ Since $$\rm\,10\,$$ is coprime to $$\rm\,d,\,$$ by the Euler-Fermat theorem we may choose $$\rm\,k = \phi(d),\,$$ which completes the proof sketch. For the converse, see this answer.

• Although this post is old, I have a question: what if k is not unique, that is what if 10^k = 1 mod d, has more than one solution? This means there are at least two different representations of c, right? This is impossible, hence k is unique right? Commented Jan 16, 2018 at 13:19
• Well, k is not unique since if k_1 is a solution then also 2k_1 is a solution; thus we may choose the least k that satisfy that equation Commented Jan 16, 2018 at 13:27
• so here $\bar{c}$ is a compact form of writing $\overline{c_1 c_2 \dots c_k}$, and represents the purely periodic part? And then $a$ and it's indexed counterpart represent the possibility of a non repeating part that precedes the periodic part? So the second line of your proof eliminates the non-repeating decimal part which has length $n$. Next you form an integer $c$ by shifting left by order $k$. I'm starting to see the underlying theory behind this stuff, but I'm not quite to the point where I can apply it to find $n$ and $k$ here. I'll keep reading. Thank you. Commented Feb 17, 2020 at 1:12
• @rocksNwaves Yes, you've correctly understood it. Commented Feb 17, 2020 at 2:24
• @BillDubuque I am sorry but I don't understand the leap from step 3 to step 4. Is it possible to elaborate it more? Commented Jan 17, 2021 at 2:28

First, it’s clear that you need only look at proper fractions. Now look at the long division algorithm for calculating the decimal expansion of a rational number. At each stage you get a remainder. What happens if you get a remainder of $0$ at some stage? If you don’t ever get a remainder of $0$, can you keep getting different remainders forever, or must a remainder repeat at some point? What happens if you do get a repeated remainder?

Remainders must be less than the divisor. So, for example, if you divide the numerator by the denominator, n, the only remainders can lie between 0 (in which case the division ends) and n-1. What happens if and when you run out of remainders (i.e. you've used all of the numbers between 1 and n-1)? You will be facing division of some remainder, r, by n again. You've been there and done that so you know what the next remainder (hence, the next dividend) will be. And so on...