TITLE: How can I prove that all rational numbers are either terminating decimal or repeating decimal numerals?
QUESTION [31 upvotes]: 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.

REPLY [27 votes]: 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.