Why does $1$ divided by $p$ have $p-1$ repeating decimals? Part of solving a bigger problem, I discovered that when dividing $1$ with a prime number $p$ > 11, the results has $p-1$ repeating decimals.
Examples: $\dfrac 1{23} = 0.\underline{0434782608695652173913}0434782608695...$
As far as I could tell, this happens for all primes I tested.
I can't at this time see the logic in this, but recall that Euler's Totient Function gives a result of $p-1$ for all primes $p$, so I tested to see if there were any other similarities between ETF and repeating decimals, but as far as I can see, it only "matches" primes.
I've search for more information about this, but have not been lucky yet.
Can anyone elaborate on this "phenomenon"?

If a decimal $x$ repeats after $k$ digits, then the fraction is just that number over a bunch of 9's: $$x = a \big(1 + 10^{-k} + 10^{-2k} + \dots \big) =  \frac{a}{1 - 10^{-k}}$$
Let's try the decimal number $\frac{1}{7} = 0.\overline{142857}$ then we can write the fraction as:
$$ \frac{1}{7} = \frac{142857}{999999} $$
Indeed we can check that $7 \times 142857 = 999999$

Fermat's little theorem has that $10^{p-1} \equiv 1 \mod p$ for any prime.   Therefore 
$$  \frac{10^{p-1} - 1}{p} = a\in \mathbb{Z}$$
is always an integer.  Then finally we can solve the equation for repeating decimal expansion:
$$  \frac{1}{p} = \frac{a}{10^{p-1} - 1} = (a \times 10^{1-p})(1 + 10^{1-p} + 10^{2(1-p)} + \dots)$$
This trick always works.  Here is another instance there the 9's trick works.  Here we get a string of 22 of them.
$$ 434782608695652173913 \times 23 =9\;999\;9 99\;999 \;999\;99 9\;999\;999$$

This a very special case of Markov partition in dynamical systems.  We can always split $[0,1]$ into intervals:
$$ \big[0, \frac{1}{p}\big], \big[\frac{1}{p}, \frac{2}{p}\big],\dots \big[\frac{p-1}{p}, 1\big],$$
This partition behaves nicely with respect to the shift map $T: x \mapsto px (\mod 1)$... 

See: Roy Adler Symbolic Dynamics and Markov Partitions.
