Why the sum of $n$ seems equals the period of the binary expansion of $1/n$? The sum of $n$(suppose $n$ is positive odd,using $n=23$ as an example):
Step 1 : Get the odd part of  $23 + ~~1 $, which is $~~3$,$~~3\times2^3=23 + ~~ 1$,get $s_1 = 3$
  Step 2 : Get the odd part of  $23 + ~~3 $, which is $13$,$13\times2^1=23 + ~~ 3$,get $s_2 = 1$
  Step 3 : Get the odd part of  $23 +  13 $, which is $~~9$,$~~9\times2^2=23 +  13$,get $s_3 = 2$
  Step 4 : Get the odd part of  $23 +  ~~9 $, which is $~~1$,$~~1\times2^5=23 +  ~~9$,get $s_4 = 5$ 
Continuing this operation (with $23 + 1$) repeats the same steps as above. There are $4$ steps in the cycle, so the cycle length of $23$ is $4$，and the sum of $23$ is $s_1 + s_2 + s_3 + s_4 = 11$.
The period of the binary expansion of $1/23$ is $11$,so why the sum of $23$ seems equals the period of the binary expansion of $1/23$?

Consider the sequence $a_i = 2^{-i} \pmod{23}$
$$
\begin{array}{l}
a_0 = 1,~a_1=12,~a_2=6 \\
a_3 = 3 \\
a_4 = 13, ~ a_5=18, \\
a_6=9, ~ a_7 = 16, a_8=8, a_9=4, a_{10}=2 \\
a_{11} = 1 = a_0
\end{array}
$$
Your steps of "get the odd part" are precisely finding the next odd number in this sequence, your $s_i$ are counting all of the steps, and the sum $\sum s_i$ is the order of 2 modulo 23.
Let $n=\operatorname{ord}_p 2$ be the order of 2 modulo a prime $p$ and $m$ the period of the binary expansion of $1/p$. Then for some positive integer $k$
$$
2^n = pk+1 \\
2^n\frac{1}{p} = k + \frac{1}{p}
$$
That is, the binary representation of $1/p$ repeats after $n$ bits, so $n\mid m$. Similarly, for some positive integer $j$
$$
2^m \frac{1}{p} = j + \frac{1}{p} \\
2^m = jp + 1
$$
so also $m\mid n$ and hence $n=m$.
