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

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.