# Prove that a fraction that has terminating decimals has its denominator as a multiple of only 2 and 5's. [duplicate]

this is a number systems question and I am currently trying to prove this statement :

"A fraction $\frac{a}{b}$ (with $a, b \in \mathbb{Z}$, where $b\neq0$) in lowest terms has a terminating decimal if and only if the prime factorization of b has only factors of 2 and factors of 5."

I am not sure how to start the proof is it's very general so any tips are much appreciated.Thank you very much in advance !

• Hint: Say your decimal, $x$, terminates after $n$ steps. Then $10^nx$ is an integer. – lulu Nov 13 '16 at 15:51

$$\frac{a}{b}=a_1...a_k.b_1...b_n \Rightarrow \frac{a}{b}=\frac{a_1...a_kb_1...b_n}{10^n}$$
Thus $\frac{a}{b}$ can be obtained by reducing the RHS.
As a more general solution, writing a number $x$ in base $k$ actually means writing the series $$x=\sum_{i=n}^N a_n k^n=a_n k^n+a_{n+1}k^{n+1}+\dots+a_N k^N$$ where the coefficients $a_n$ are integers in $[0,k-1]$, for some $n\le N$ and we allow $n$ to be negative or even $-\infty$ (in the case of non terminating $k$-simal expansion). For instance, the number $5/4\in\mathbb{R}$ is written in decimal as $$5/4=(1.25)_{10}=1\cdot 10^{0}+2\cdot 10^{-1}+5\cdot 10^{-2}$$ or you could use base $2$ (for instance) and $$5/4=1+\frac{1}{4}=1\cdot 2^{0}+0\cdot 2^{-1}+1\cdot 2^{-2}=(1.01)_2$$
Now, if your number is rational i.e. $x=a/b$ for some integers $a,b$ and your $k$-simal expansion terminates $m$ positions after the separator, you can write $$\frac{a}{b}=x_{-m}k^{-m}+x_{-m+1}k^{-m+1}+\dots+x_N k^N$$ for some $N\ge m$. By multiplying by $k^m$, you get $$\frac{k^m a}{b}=x_{-m}k^{0}+x_{-m+1}k^{1}+\dots+x_N k^{N+m}$$ but now the right hand side is an integer number, hence $b$ divides $k^m a$. Since we assumed that $(a,b)$ are coprime, this means that $b$ divides $k^m$, and in definitive $b$ is made of only those primes dividing $k$ (which, in the case $k=10$, are exactly $2$ and $5$).
We can prove this easily by proving the reverse i.e we can prove that any number with a terminating decimal expansion is of the form $a/b$ where $a$ and $b$ are coprimes and $a,b \in N.$ Let $\alpha$ be a number with a terminating decimal expansion. Then it will be of form $$n/{10^k}$$ where $n,k\in N.$ Now this number can be written of form $$n/({2^k}×{5^k})$$ Let numerator and denominator have a common factor $g$ such that $g\in N$ . After dividing numerator and denominator by $g$ let the number thus obtained be $$d/({2^z}×{5^h}).$$ where $z,h\in N$ . Thus number clearly satisfies a number of form$\hspace{1 mm}$$a/b$ where $a$ and $b$ are coprimes and $a,b \in N$ therfore b will be equal to ${2^z}×{5^h}$ i.e. it will be factorizable only into multiples of 2 and 5. Hence proved.