Look at the classical division algorithm: after you have exhausted the digits of the numerator, you will continue appending zeroes 'past the decimal point'. As the remainder is smaller than the divisor, it is finite and the same values will come back periodically. The period length of the decimals cannot exceed the value of the divisor minus $1$.
Base $10$ example, $83/7$:
$83\div 7=10$, remainder $1$ ($=8-7$).
$83\div 7=11$, remainder $6$ ($=83-7\cdot11$).
$83\div 7=11.8$, remainder $4$ ($=830-7\cdot118$).
$83\div 7=11.85$, remainder $5$ ($=8300-7\cdot1185$).
$83\div 7=11.857$, remainder $1$ ($=83000-7\cdot11857$).
$83\div 7=11.8571$, remainder $3$ (=$\cdots$).
$83\div 7=11.85714$, remainder $2$.
$83\div 7=11.857142$, remainder $6$.
$83\div 7=11.8571428$, remainder $4$.
$\cdots$
Conversely, when you have a periodic number, if you shift it left by one period and subtract the original, you obtain a terminating number by cancellation of the decimals.
$$11857142.8571428571428571428\cdots-11.8571428571428571428\cdots=11857131,$$ hence the number is
$$\frac{11857131}{999999}=\frac{83}7.$$
Let me elaborate a bit on my comments:
Suppose $n$ is coprime to $10$. Then we have $10^{\varphi(n)}\equiv 1\pmod n$, and thus it follows that $10^k\equiv 1\pmod n$ for some $k$ dividing $\varphi(n)$. Choose the smallest such $k$. This corresponds to 3. in your suggested algorithm. Then $n$ must divide $10^k-1$ and so all prime factors of $n$ can be found in
$$
10^k-1=\overbrace{999......999}^{\text{the digit }9\text{ repeated }k\text{ times}}
$$
Now for any $r\in\mathbb N$ such that $r<n$ we then have
$$
\frac rn=\frac{d}{10^k-1}
$$
where $d<10^k-1$ so that the above rational is recognized as a number in $[0,1)$ having a recurring decimal expansion of length $k$. The digits of $d$ with zeros padded on the left if necessary will then be the digits of the $k$-cycle.
Suppose now we are given any coprime natural numbers $m,n$ where one of them possibly is not coprime to $10$. Then we may find the minimal $s\in\mathbb Z$ such that
$$
10^s\cdot\frac mn=\frac{m'}{n'}
$$
where $m',n'$ are coprime and $n'$ is coprime to $10$. In that case
$$
\frac{m'}{n'}=\frac{qn'+r}{n'}=q+\frac d{10^k-1}
$$
with $0\leq r<n$ and thus $0\leq d<10^k-1$. Since $s$ was chosen to be minimal, we cannot divide by $10$ any more times without the denominator sharing factors with $10$. Thus none of the decimals in $q$ will be recurring. In effect, $\frac{m'}{n'}$ has its digits precisely split into its recurring part and its non-recurring part by the decimal point. It will be of the form
$$
\frac{m'}{n'}=q.\overline{00...d}
$$
where the zeros are only padded to the left if necessary in order to match the period length, $k$. Finally we conclude that
$$
\frac mn=10^{-s}\cdot\frac{m'}{n'}=10^{-s}q.\overline{00...d}
$$
where $q$ is the non-recurring part and $\overline{00...d}$ is the recurring part. Here $s$ denotes the length of the antiperiod. Note that $s$ can also be negative as in
$$
54321.\overline{321}=10^3\cdot 54.\overline{321}
$$
which in this sense has an antiperiod of length $s=-3$. Also note that $m'$ will be divisible by either $2$ or $5$ or none of them, but never both since then a smaller value of $s$ would be possible.
Best Answer
Hint
The number of digits of $x$ after the point is the least integer $n$ such that $10^nx$ is integer.