Today I Learned

(back up to October)

October 19th

Today I learned about Midy's Theorem . The statement is more magical than the proof. Basically, if the fraction $\frac ap\in\QQ\setminus\ZZ$ (for prime denominator $p$) has an even period when expanded in base $b,$ then the sum of the first and second halves of the period is of the form $b^k-1.$ By way of example, $\frac1{13}=0.\overline{076923},$ and so\[076+923=\boxed{999}.\]Similarly, $\frac{10}{137}=0.\overline{07299270},$\[0729+9270=\boxed{9999}.\]

Anyways, as promised, the proof is not terribly exciting, but it simultaneously touches a lot of low-machinery elementary number theory, which is cute. There is a clean generalization of this to when we can divide the decimal expansion into any number of equal parts (not just $2$), but we won't bother with this. Suppose that we have $\frac ap$ satisfying the conditions so that\[\frac ap=(0.\overline{a_1\cdots a_{2n}})_b=\frac A{b^{2n}-1},\]where $A=\overline{a_1\cdots a_{2n}}_b.$ The clever part of this proof, really, is combining the divisibility condition on the period with the actual fact that it is the period. Namely, to use the divisibility, write\[\frac ap=\frac A{\left(b^n+1\right)\left(b^n-1\right)}.\]But because the period of $\frac ap$ is $2n,$ we have that $p$ cannot divide into $b^n-1,$ for then the period would no more than $k.$ (In particular, the base-$b$ expansion of $\frac 1p$ would be $\frac{b^n-1}p.$) But $p$ must divide the denominator of the right-hand side somehow, so it must divide into $b^n+1,$ implying that\[\frac A{b^n-1}=a\cdot\frac{b^n+1}p\in\ZZ.\]This means that $A\equiv0\pmod{b^k-1}.$

To finish, we then combine the above with the divisibility by $9$ trick. We write\[A=\overline{a_1\cdots a_{2n}}=\underbrace{(\overline{a_1\cdots a_n})_b}_{A_1}\cdot b^n+\underbrace{(\overline{a_{n+1}\cdots a_{2n}})_b}_{A_2},\]where $A_1$ and $A_2$ are the first and second halves of the base-$b$ expansion. Now, it remains to show that $A_1+A_2=b^n-1.$ The above shows that $b^n-1$ divides $A_1+A_2\equiv A,$ so we just need bounding information.

On one hand, they can't both be $0,$ for then the period would be $1,$ so $A_1+A_2 \gt 0.$ On the other hand, the fact that each has $k$ digits implies that $A_1$ and $A_2$ are each less than $b^k-1,$ so $A_1+A_2 \lt 2\left(b^n-1\right).$ The equality follows.