For the period of something like $1/d$ where $d$ is a positive integer, I saw an algorithm repeatedly doing:
$\begin{align*}r &= 1\\ r &= 10r \bmod d \quad\text{ (until } r = 1) \end{align*}$
and the number of steps was the period.
For the period of something like $1/d$ where $d$ is a positive integer, I saw an algorithm repeatedly doing:
$\begin{align*}r &= 1\\ r &= 10r \bmod d \quad\text{ (until } r = 1) \end{align*}$
and the number of steps was the period.
This is just long division. Once you reach the end you take the remainder over, put a zero next to it and repeat the process, eg:
$ 2/5 = (2.0)/5 = 0.4 $
So in this case since we are doing $1/d$ we start with one. How many times this process is repeated is just how many times we carried the remainder over which is the length of the decimal.