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[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.
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 10k − 1 with bk − 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.
In other words, 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 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.