Length of digits before the period in decimal expansion for rational numbers
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.