Detecting a nonrepeating decimal For two numbers $x$ and $y$, both rational numbers, how can we detect if $\frac xy$ is going to be non-terminating, non-repeating decimal?
 A: First reduce the fraction to lowest terms; that is, assume that $x,y \in \Bbb Z$ with $\gcd(x,y)=1$. Then $\frac{x}{y}$ terminates (i.e., ends in a string of $0$s or $9$s) if and only if $y=2^r5^s$ for some $r,s \in \Bbb Z^{\geq 0}$.
In general, in base $n = p_1^{a_1}\cdots p_k^{a_k}$, the fraction will terminate if and only if $y = p_1^{b_1}\cdots p_k^{b_k}$ for some non-negative $b_i$.
If the fraction does not terminate, then it will repeat, since it is rational. Only irrational numbers have decimal expansions that do not terminate or repeat.
A: Since $x/y$ is rational let $x/y=\pm m/n$ where $m,n$ are positive integers. Now compute the decimal places for $m/n$ in base $10$ (or in any base) by ordinary long division. Eventually every digit that you "bring down" to append to the right-hand side of the remainder will always be a $0.$ There are only $n$ possible remainders $(0,1,...,n-1).$ In the next  $n+1$ steps at least one of these remainders will occur at least twice. Therefore, as soon as a remainder repeats (after all the "bring-downs" are all $0$'s) the pattern will repeat.
I have met university graduates who didn't know this.   
