Take the 2-minute tour ×
MathOverflow is a question and answer site for professional mathematicians. It's 100% free, no registration required.

Take a prime other than 2,3 or 5 and look at the part of it that repeats in base 10. Is it true that the sum of the digits in the end divided by the period(number of repeated digits id always $\frac{9}{2}$ Can we extend this result to other bases? Why does this happen?


This is a crosspost from math.se

share|improve this question
It's false for $p=31$. I can't really explain why it holds for smaller $p$, besides that $9/2$ should be the most common average digit value since it is the average of the 10 base 10 digits. –  Jack Huizenga Mar 7 at 1:34
It seems to be true for a lot of them though, can you find out for how many it is true for primes between 1 and 1000? –  user4140 Mar 7 at 1:37
1/37 = .027027... –  Aaron Bergman Mar 7 at 1:37
About 2/3rds of the first 10000 primes satisfy the property. –  Jack Huizenga Mar 7 at 1:50
It's not too hard to prove the sum of the repeating digits is a multiple of 9, so with the 9/2 average, that should get you a pretty high density. –  Aaron Bergman Mar 7 at 1:59

2 Answers 2

up vote 11 down vote accepted

Note first that the counterexamples to user4140's observation involve decimal expansions with odd period length. In the case of even period length, what user4140 has observed is a consequence of Midy's theorem, which says the following: let p be a prime not dividing 10, and suppose that the repeating part of the decimal expansion of 1/p has even length. Corresponding digits in the first and second half of the repeating part then add to 9. (For example, we have 1/7 = 0.142857 and 1+8 = 4+5 = 2+7 = 9.)

The proof of Midy's theorem is not hard and essentially comes down to the fact that modulo p there are exactly two numbers whose square is 1, namely 1 and -1. The same argument applies to the decimal expansion of 1/n whenever there are exactly two numbers whose square is 1 modulo n. (The n with this property are thus n = 4 and n = a power of an odd prime.) The argument also applies to base-b expansions, where "b-1" plays the role of "9".

share|improve this answer

The reason why this seems to be true for lots of cases is that it is true when the period of the fraction is even (hence different from 3) and $p$ is coprime with $10$ (hence different from $2$ or $5$). This is a known result which follows from Fermat's little theorem and actually the fraction can have any numerator $r$, since it doesn't affect the result. Here is the proof:

For a prime $p$ coprime with $10$ Fermat's theorem guarantees the existence of an integer $c$ such that $10^{p-1}-1=cp$. Hence, supposing the period is even, say, $2t$, one has:


Assume wlog that $r < p$. The right hand side is the sum of a geometric series showing that, expressed in base $10$, the period is exactly $rc$. Let $M$ and $N$ be the two halves of the block of digits. It is enough to prove that $M+N=10^t-1$, since then the sum of the digits of the period (which is precisely $M+N$) will be exactly $9t$ (as $10^t-1$ consists of $t$ nines in base $10$). Now, we had $(10^{t}-1)(10^{t}+1)=cp$, and it is easy to see that $p$ does not divide $10^{t}-1$ (otherwise, the number of digits in the period cannot be $2t$, since it is always the smallest integer $k$ such that $p$ divides $10^k-1$). Hence, $p$ divides $10^k+1$. The equation displayed above now implies:


and so:


while $M, N \leq 10^t-1$. Since the left hand side is an integer, so is the fraction on the right hand side, and the previous inequalities proves that $M+N$ is at most $2(10^t-1)$, so the integer in question is $1$ or $2$. But it cannot be $2$, since otherwise the period would consists only of nines, which is absurd. That finishes the proof.

The same idea of the proof can be adapted to show a similar statement for a general base $b$, in which case one just has to choose a prime $p$ coprime with $b$ to be able to use Fermat's theorem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.