# Rational numbers and periodic decimal representation [duplicate]

I'm trying to prove that a number is rational if and only if it has an eventually periodic decimal expansion. One part is simple; without loss of generality we consider $q=0.\overline{d_1\dots d_k},$ set $p=d_1\dots d_k$ so $$q=\sum\limits_{n=1}^{\infty}\frac{p}{10^{kn}}=\frac{p}{10^k-1}\in\mathbb{Q}.$$ To prove the converse, I have been given the hint to apply the pigeonhole principle. Can someone give some suggestions (or just post the answer if you like; it's not homework) because I'm not too familiar or confident in using the pigeonhole principle, even though I feel like it might be some simple trick I don't see right now.

Thanks.

• How about $$\frac1{2^a 5^b}?$$ Is it periodic & rational ? Commented Aug 14, 2014 at 8:43
• You should probably say something like "eventually periodic". I think this is what @labbhattacharjee is referring to.
– MPW
Commented Aug 14, 2014 at 8:50

To see that every rational has an eventually repeating decimal representation, suppose the rational is $\pm a/b$ with $a\geq 0$ and $b>1$ (we may exclude $b=1$ since then $a/b$ is integral and so has a decimal representation ending in a repeating string of zeroes already). Then just perform long division of $a$ by $b$. At each successive step in the long division, you either get a remainder of $0$ (and you are done, the decimal representation ends in a repeating string of zeroes), or you get a positive integral remainder which must lie in $\{1,\ldots,b-1\}$. There are at most $b-1$ possible distinct remainders, so by the $b^{\textrm{th}}$ successive step you must have a repeated remainder; the sequences of successive remainders must then repeat those previously encountered since they repeat, in order, producing the same sequence of generated digits in the quotient as desired.

Let $q=\dfrac{a}{b}\in\mathbb Q$ be given. Suppose this rational has decimal expansion $$q=\frac{a}{b}=c.d_1d_2...$$ Then we have more generally that $$10^kq=c_k.d_{k+1}d_{k+2}...$$ where $10^ka=bc_k+r_k$ and $r_k\in\{0,1,...,b-1\}$ is the remainder after the division $10^ka/b$. Therefore $$\frac{r_k}{b}=0.d_{k+1}d_{k+2}...$$ Now since $r_k$ can only assume finitely many values (this is essentially the apllying pigeonhole principle) the remainder and thus the decimal expansion will eventually repeat itself so that $r_k=r_m$ for some $k<m$. Thus $$0.d_{k+1}d_{k+2}...=0.d_{m+1}d_{m+2}...$$ showing that the decimal expansion is periodic with period $m-k$.

Since you just wanted the answer here it is: Proof that every repeating decimal is rational I had to figure it out to answer a Project Euler problem, the principle is the same as the other answers.

Let $$a,b\in\mathbb N$$, and assume we want to prove that the decimal expansion of $$b/a$$ is eventually periodic. If $$a>b$$, then there exist unique $$q,r\in\mathbb Z$$ such that $$a=qb+r$$ with $$0\leq r. so $$a/b=q+r/b$$. Hence, if we can show that $$r/b$$ is eventually periodic, we are done. So WLOG assume that $$a.

One can prove that we can construct a decimal expansion of $$a/b$$ satisfying the following properties:

Define a sequence $$(r_n)$$ recursively, by setting $$r_0=$$ and $$r_n=10 r_{n-1}-d_{n-1}\cdot b$$ such that $$0\leq r_{n-1} (note that $$r_n$$ is uniquely determined by the division-with-remainder theorem). Then a decimal expansion of $$a/b$$ is given by $$=\sum_{i\leq -1} d_i 10^i$$.

See e.g. §16 in Elementary Analysis by Kenneth Ross.

Using this, and Theorem 16.3 in Ross (which says that each real number has either a unique decimal expansion or two decimal expansions, one ending in a sequence of all $$0$$'s and the other ending in a sequence of al $$9$$'s), one can indeed invoke the pigeon principle:

Each $$r_{n-1}$$ determines $$r_n$$ uniquely, and there can at most $$b+1$$ distinct $$r_n$$. So there exist integers $$m$$ and $$p$$ such that $$0\leq m and $$r_m=r_{m+p}$$. One can then prove inductively that for $$k\geq m+1$$, $$r_k=r_{k+p}$$. For the details I refer to Theorem 16.5 in Ross.

• Please strive not to post more (dupe) answers to dupes of FAQs, cf. recent site policy announcement here. Commented Oct 2, 2023 at 6:49
• @BillDubuque My apologies, I wasn't aware that this question was a dupe. I don't think my answer is a dupe, as the answers I saw weren't clear to me, so when I found a formal proof in Ross, I thought it might be helpful for someone else in the future too. Can I transfer this answer to the other question, or do you still consider my answer a dupe? In which case I'll delete it. Commented Oct 2, 2023 at 7:01
• It is ok to leave it here. Commented Oct 2, 2023 at 7:05