Why is the decimal representation of $\frac17$ "cyclical"?

$\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.


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]]]&].)


It works with 1/19 = 0.(052631578947368421) too, while n/13 has two cycles: 1/13 = 0.(076923), 2/13 = 0.(153846), 3/13 = 0.(230769), 4/13 = 0.(307692), 5/13 = 0.(384615), and so on.

That a cycle must appear when you have a prime number p different from the base in which we work (so in base 10 different from 2 and 5) is clear: if you perform the long division 1/p, sooner or later partial quotients must be repeated, and from that point on the quotients repeat themselves. The length of the cycle must be a divisor of p-1: it may be short (think at 1/11 = 0.(09) ) or have the maximum possible lenght like the cases of 7 and 19.

Wikipedia has an article on Cyclic numbers, and some other example is also here; unfortunately no sufficient rule is given for a number to have its inverse cyclical.