Period of the decimal expression for the rational number $\frac{1}{n}$ is at most $n-1$

When you carry out long division of $1$ by $n$, either the process terminates and you have a finite decimal, or you obtain a sequence of remainders among $1, 2, \dots, n-1$. Once a remainder is repeated, the decimals must start repeating too. Since there are only $n-1$ possible remainders, the repetition must occur by the $n$th decimal place at the latest. The period is then the distance between this and the previous occurrence of the same remainder, which must be at most $n-1$ decimal places.


Clearly it suffices to take $n$ such that $n$ is comprime with $10$. This is because the periods of $\frac{1}{5k},\frac{1}{2k}$ and $\frac{1}{k}$ are all the same.

So suppose $n>1$ is sn integer coprime to $n$.

The period of $n$ is equal the smallest positive integer $a$ such that $10^a-1$ is a multiple of $n$ (because each of the blocks in the expansion of $\frac{1}{n}$ must yield a sequence of nines when multiplied by $n$).

Notice that $n$ divides $10^{\varphi(a)}-1$. Since $\varphi(a)\leq a-1$ we are done.

Notice that equality holds if and only if $n$ is primes and $10$ is a primitive root $\bmod n$.