In mathematics, Midy's theorem, named after French mathematician E. Midy,[1] 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
a | |
p |
=0.\overline{a1a2a3...anan+1...a2n
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,
ai+ai+n=9
a1...an+an+1...a2n=10n-1.
For example,
1 | |
13 |
=0.\overline{076923}and076+923=999.
1 | |
17 |
=0.\overline{0588235294117647}and05882352+94117647=99999999.
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[2] 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 10k - 1.
For example,
1 | |
19 |
=0.\overline{052631578947368421}
052631+578947+368421=999999.
052+631+578+947+368+421=2997=3 x 999.
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 10k - 1 with bk - 1 and carry out addition in base b.
For example, in octal
\begin{align} &
1 | |
19 |
=0.\overline{032745}8\\[8pt] &0328+7458=7778\\[8pt] &038+278+458=778. \end{align}
In duodecimal (using inverted two and three for ten and eleven, respectively)
\begin{align} &
1 | |
19 |
=0.\overline{076l{E}45}12\\[8pt] &07612+l{E}4512=l{EEE}12\\[8pt] &0712+6l{E}12+4512=l{EE}12\end{align}
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
\begin{align} &
a | |
p |
=[0.\overline{a1a2...a\ell}]b\\[6pt] & ⇒
a | |
p |
b\ell=[a1a2...a\ell.\overline{a1a2...a\ell}]b\\[6pt] & ⇒
a | |
p |
b\ell=N+[0.\overline{a1a2...a\ell}]
|
\\[6pt] & ⇒
a | |
p |
=
N | |
b\ell-1 |
\end{align}
where N is the integer whose expansion in base b is the string a1a2...aℓ.
Note that b ℓ - 1 is a multiple of p because (b ℓ - 1)a/p is an integer. Also bn-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 ℓ - 1 is a multiple of bk - 1. (To see this, substitute x for bk; then bℓ = xh and x - 1 is a factor of xh - 1.) Say b ℓ - 1 = m(bk - 1), so
a | = | |
p |
N | |
m(bk-1) |
.
But b ℓ - 1 is a multiple of p; bk - 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
am | = | |
p |
N | |
bk-1 |
is an integer. In other words,
N\equiv0\pmod{bk-1}.
Now split the string a1a2...aℓ into h equal parts of length k, and let these represent the integers N0...Nh - 1 in base b, so that
\begin{align} Nh-1&=[a1...ak]b\\ Nh-2&=[ak+1...a2k]b\\ &{} \vdots\\ N0&=[al-k+1...al]b \end{align}
To prove Midy's extended theorem in base b we must show that the sum of the h integers Ni is a multiple of bk - 1.
Since bk is congruent to 1 modulo bk - 1, any power of bk will also be congruent to 1 modulo bk - 1. So
h-1 | |
N=\sum | |
i=0 |
ik | |
N | |
ib |
h-1 | |
=\sum | |
i=0 |
k | |
N | |
i(b |
)i
⇒ N\equiv
h-1 | |
\sum | |
i=0 |
Ni\pmod{bk-1}
⇒
h-1 | |
\sum | |
i=0 |
Ni\equiv0\pmod{bk-1}
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 N0 and N1 are both represented by strings of k digits in base b so both satisfy
0\leqNi\leqbk-1.
N0 and N1 cannot both equal 0 (otherwise a/p = 0) and cannot both equal bk - 1 (otherwise a/p = 1), so
0<N0+N1<2(bk-1)
and since N0 + N1 is a multiple of bk - 1, it follows that
N0+N1=bk-1.
From the above,
am | |
p |
Thus
m\equiv0\pmodp
And thus for
k=
\ell | |
2 |
b\ell/2+1\equiv0\pmodp
For
k=
\ell | |
3 |
b2\ell/3+b\ell/3+1\equiv0\pmodp
and so on.