[Math] Determine whether the decimal expansion of a rational number is infinite

decimal-expansionrational numbers

This may be a naive question but I would like to know whether we can determine if a fraction (say $1/3$) will produce a rational number with an infinite number of digits after the decimal when computed (without actually computing it).

Of course computers cannot store such rational numbers accurately and they are difficult to detect after calculations have been performed and the result truncated.

Similar to how we can perform integral calculations on improper fractions to get their remainder, I wonder if we can do something similar to determine if a proper fraction will compute to an irrational number.

Best Answer

A rational number has terminating decimal expansion if the denominator (in lowest terms) has prime factors only $2$ or $5$ or both. Any other factors in the denominator yield a non-terminating decimal expansion.

Examples $$ \frac{1}{1024} = 0.0009765625\quad\text{(exactly)} $$ terminates because $1024 = 2^{10}$.

$$ \frac{1}{6} = 0.16666666666\cdots $$ is non-terminating, because $6=2\cdot3$ has a prime factor $3$.