In mathematics, Midy's theorem, named after French mathematician E. Midy, is a statement about the decimal expansion of fractions a/p where p is a prime and a/p has a repeating decimal expansion with an even period . If the period of the decimal representation of a/p is 2n, so that
then the digits in the second half of the repeating decimal period are the 9s complement of the corresponding digits in its first half. In other words,
For example,
If k is any divisor of h (where h is the number of digits of the period of the decimal expansion of a/p (where p is again a prime)), then Midy's theorem can be generalised as follows. The extended Midy's theorem states that if the repeating portion of the decimal expansion of a/p is divided into k-digit numbers, then their sum is a multiple of 10<sup>k</sup> − 1.
For example,
has a period of 18. Dividing the repeating portion into 6-digit numbers and summing them gives
Similarly, dividing the repeating portion into 3-digit numbers and summing them gives
Midy's theorem and its extension do not depend on special properties of the decimal expansion, but work equally well in any base b, provided we replace 10<sup>k</sup> − 1 with b<sup>k</sup> − 1 and carry out addition in base b.
For example, in octal
In dozenal (using inverted two and three for ten and eleven, respectively)
Short proofs of Midy's theorem can be given using results from group theory. However, it is also possible to prove Midy's theorem using elementary algebra and modular arithmetic:
Let p be a prime and a/p be a fraction between 0 and 1. Suppose the expansion of a/p in base b has a period of âÂÂ, so
where N is the integer whose expansion in base b is the string a<sub>1</sub>a<sub>2</sub>...a<sub>âÂÂ</sub>.
Note that b<sup> âÂÂ</sup> − 1 is a multiple of p because (b<sup> âÂÂ</sup> − 1)a/p is an integer. Also b<sup>n</sup>−1 is not a multiple of p for any value of n less than âÂÂ, because otherwise the repeating period of a/p in base b would be less than âÂÂ.
Now suppose that â = hk. Then b<sup> âÂÂ</sup> − 1 is a multiple of b<sup>k</sup> − 1. (To see this, substitute x for b<sup>k</sup>; then b<sup>âÂÂ</sup> = x<sup>h</sup> and x − 1 is a factor of x<sup>h</sup> − 1. ) Say b<sup> âÂÂ</sup> − 1 = m(b<sup>k</sup> − 1), so
But b<sup> âÂÂ</sup> − 1 is a multiple of p; b<sup>k</sup> − 1 is not a multiple of p (because k is less than â ); and p is a prime; so m must be a multiple of p and
is an integer. In other words,
Now split the string a<sub>1</sub>a<sub>2</sub>...a<sub>âÂÂ</sub> into h equal parts of length k, and let these represent the integers N<sub>0</sub>...N<sub>h − 1</sub> in base b, so that
To prove Midy's extended theorem in base b we must show that the sum of the h integers N<sub>i</sub> is a multiple of b<sup>k</sup> − 1.
Since b<sup>k</sup> is congruent to 1 modulo b<sup>k</sup> − 1, any power of b<sup>k</sup> will also be congruent to 1 modulo b<sup>k</sup> − 1. So
which proves Midy's extended theorem in base b.
To prove the original Midy's theorem, take the special case where h = 2. Note that N<sub>0</sub> and N<sub>1</sub> are both represented by strings of k digits in base b so both satisfy
N<sub>0</sub> and N<sub>1</sub> cannot both equal 0 (otherwise a/p = 0) and cannot both equal b<sup>k</sup> − 1 (otherwise a/p = 1), so
and since N<sub>0</sub> + N<sub>1</sub> is a multiple of b<sup>k</sup> − 1, it follows that
From the above, is an integer
Thus
And thus for
For and is an integer
and so on.