Number Theory – Why is the Decimal Representation of 1/7 Cyclical?

decimal-expansionfractionsnumber theory

$\frac17 = 0.(142857)$…

with the digits in the parentheses repeating.

I understand that the reason it's a repeating fraction is because $7$ and $10$ are coprime. But this…cyclical nature is something that is not observed by any other reciprocal of any natural number that I know of (besides multiples of $7$). (if I am wrong, I hope that I may find others through this question)

By "cyclical," I mean:

1/7 = 0.(142857)...
2/7 = 0.(285714)...
3/7 = 0.(428571)...
4/7 = 0.(571428)...
5/7 = 0.(714285)...
6/7 = 0.(857142)...

Where all of the repeating digits are the same string of digits, but shifted. Not just a simple "they are all the same digits re-arranged", but the same digits in the same order, but shifted.

Or perhaps more strikingly, from the wikipedia article:

1 × 142,857 = 142,857
2 × 142,857 = 285,714
3 × 142,857 = 428,571
4 × 142,857 = 571,428
5 × 142,857 = 714,285
6 × 142,857 = 857,142

What is it about the number $7$ in relation to the base $10$ (and its prime factorization $2\cdot 5$?) that allows its reciprocal to behave this way? Is it (and its multiples) unique in having this property?

Wikipedia has an article on this subject, and gives a form for deriving them and constructing arbitrary ones, but does little to show the "why", and finding what numbers have cyclic inverses.

Best Answer

For a prime p, the length of the repeating block of $\frac{1}{p}$ is the least positive integer k for which $p|(10^k-1)$. As in mau's answer, $k|(p-1)$, so $k\leq p-1$. When $k=p-1$, then $\frac{1}{p}$ and its multiples behave as discussed in the question.

Of the first 100 primes, this is true for 7, 17, 19, 23, 29, 47, 59, 61, 97, 109, 113, 131, 149, 167, 179, 181, 193, 223, 229, 233, 257, 263, 269, 313, 337, 367, 379, 383, 389, 419, 433, 461, 487, 491, 499, 503, 509, 541 (sequence A001913 in OEIS).

(List generated in Mathematica using Select[Table[Prime[n], {n, 1, 100}], # - 1 == Length[RealDigits[1/#][[1]][[1]]]&].)