Faith Welch

2022-07-23

Algorithm for converting fraction into (recurring) decimal
I need to determine whether fraction is recurring decimal or not (what are conditions for it?), find period and output it as $\frac{1}{3}=0.\overline{3}$
If it is not recurring, then I already have algorithm.

phinny5608tt

Notice that if you have a repeating decimal
$n=0.\overline{{D}_{1}{D}_{2}...{D}_{k}}$
where each ${D}_{i}$ is a digit, you can say that
${10}^{k}n={D}_{1}{D}_{2}...{D}_{k}.\overline{{D}_{1}{D}_{2}...{D}_{k}}$
and so
${10}^{k}n-n={D}_{1}{D}_{2}...{D}_{k}$
and
$n=\frac{{D}_{1}{D}_{2}...{D}_{k}}{{10}^{k}-1}$
This means that $n$ can only be a repeating decimal if $n$ can be expressed in the form
$n=\frac{a}{{10}^{b}-1}$
and so if you are given a number in the form
$I+\frac{h}{j}$
Where $I$ is an integer and $j>h$, then it can only be a repeating decimal if $j$ evenly divides ${10}^{k}-1$ for some $k$. For example, for $j=1,2,5,10$ it will never be a repeating decimal.
Does this help?

Do you have a similar question?