Date of this Version
It is well known that a real number is rational if and only if its decimal expansion is a repeating decimal. For example, 2/7 = .285714285714 . . . . Many students also know that if n/m is a rational number reduced to lowest terms (that is, n and m relatively prime), then the number of repeated digits (we call this the length of period) depends only on m. Thus all fractions with denominator 7 have length of period 6. A sharp-eyed student may also notice that when the period (that is, the repeating digits) for 2/7 is split into its two half-periods 285 and 714, then the sum 285 + 714 = 999 is a string of nines. A little experimentation makes it appear likely that this is always true for a fraction with the denominator 7, as well as for fractions with denominators 11, 13, or 17. A natural conjecture is that all primes with even length of period (note that many primes, such as 3 and 31, have odd length of period) will have a similar property. This conjecture is, in fact, true but it is unfortunately not a criterion for primeness, since many composite numbers (such as 77) also have the property. The relevant theorem appears not to be well known, although it was discovered many years ago. (L. E. Dickson [see 1, p. 163] attributes the result to E. Midy, Nantes, 1836). The proof of the theorem is simple and elegant, and since it also provides a nice example of the usefulness of the concept of the order of an element of a group, it deserves to be better known.
In the following, we will develop from the beginning the theory of repeating decimals. This is to provide the necessary machinery for the proof of Midy's theorem, as well as for completeness.