# Prove that the decimal expansion of $\frac{p}{q}$ with $\gcd{(p, q)} = 1$ terminates iff $q = 2^{r}5^{s}$ for some $r, s$

Proof:

Let $\frac{p}{q} \in \mathbb{Q}$ and $\gcd{(p, q)} = 1$. Suppose $q = 2^{r}5^{s}$, for some r, s. This is the same as saying multiplying by $10$ sufficiently many times I obtain an integer. Meaning $10^{n} \times \frac{p}{q} \in \mathbb{Z}$ for sufficiently large $n$.

Suppose the decimal expansion of $\frac{p}{q}$ terminates:

$$\frac{p}{q} = a_{o}.a_{1}a_{2}\cdots a_{n}$$ $$= a_{0} + \frac{a_{1}}{10^{1}} + \frac{a_{2}}{10^{2}} + \cdots + \frac{a_{n}}{10^{n}}$$ $$= \frac{10^{n}a_{0} + 10^{n-1}a_{1} + \cdots + a_{n}}{10^{n}}$$

Now at this point I am left with "cancelling common factors of $2, 5$ from top and bottom yields $q = 2^{r}5^{s}$ for some $r, s$".

I am struggling to understand where the common factors of $2$ and $5$ are. There isn't even a factor of $10$ multiplying $a_{n}$.

-

## 1 Answer

The last digit $a_n$ might itself be even (in which case there's at least one common factor of $2$) or $5$, in which case there's at least one common factor of $5$.

-
Well this means $a_{n}$ must be $2$ or $5$ since both are prime but surely we can't just make this assumption as $a_{i} \in \lbrace0, \cdots 9\rbrace$ for some $i$. –  user2850514 Dec 29 '13 at 22:04
@user2850514 If there are no factors to cancel it is even easier to cancel the common factors by doing nothing. This is not a problem. –  Phira Dec 29 '13 at 22:06
Nobody says that the digits are prime. And there are no assumptions being made -- the text you quote just says that even if there are any common factors of 2 or 5 to cancel out while bringing the fraction to lowest terms (for example, if you're trying to convert 0.625), then what's left in the denominator afterwards will still have the form $2^r5^s$. –  Henning Makholm Dec 29 '13 at 22:08
Ah, I understand, so we are cancelling common factors of 2 and 5 if present. If none are present then $10^{n} = 2^{r}5^{s}$? –  user2850514 Dec 29 '13 at 22:15
@user2850514: If there's nothing to cancel, then naturally $10^n = 2^n5^n$, so $r=s=n$. –  Henning Makholm Dec 29 '13 at 22:17