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"?
 A: Consider $\frac{1}{n}$ in base $m$, where $\gcd(n,m)=1$ for simplicity. We wish to multiply numerator and denominator by a number $k$ so that the denominator becomes $m^e-1$ for some exponent $e$.
Consider powers $1,m,m^2,\cdots$ mod $n$. This sequence repeats. That is, $m$ has some multiplicative order $e$ in the group of units mod $n$. Then $m^e-1=kn$ for some $k$.
We may conclude that
$$\frac{1}{n}=\frac{k}{kn}=\frac{k}{m^e-1}=p^{-e}\frac{k}{1-m^{-e}}=km^{-e}+km^{-2e}+km^{-3e}\cdots $$
Now, $k<m^e$ so is less than $e$ digits in base $m$, so the above exhibits the repeating base $m$ expansion of the fraction $\frac{1}{n}$, with period $e$.
There are $\varphi(n)$ elements in the group of units mod $n$, so the multiplicative order $e$ of $m$ mod $n$ must be a divisor of $\varphi(n)$. When $p$ is prime, $\varphi(p)=p-1$.
A: 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.
A: When you divide p into 1 you get a remainder.  When you divide p into that remaineder you get a second remainder.  There are only p - 1 possible remainders.  Once you go through them all they will repeat. 
The only thing you need to figure out is why you will always have a remainder (because p, except 2 and 5, don't divide into 10) and why the remainders don't repeat until you've gone through all p-1 remainders.  Except they don't.  But their period will always divide p-1.
