# Proof of Wolstenholme's theorem

According to the theorem, if

$$1+\frac{1}{2}+\frac{1}{3}+\frac{1}{4}+\frac{1}{5}+\cdots+\frac{1}{p-1} =\frac{r}{q}$$

then we have to prove that $r\equiv0 \pmod{p^2}$.

(Given $p>3$, otherwise $1+\dfrac{1}{2}=\dfrac{3}{2}$, $3 \not\equiv 0 \pmod 9$.)

I guess there's a $(\bmod p)$ solution for this, but I don't really get how to start it.

• is $\gcd(r,q)=1?$
– Aang
Mar 9, 2013 at 13:31
• Yeah! It is in the simplified form. Mar 9, 2013 at 13:39
• Have you seen en.wikipedia.org/wiki/Wolstenholme's_theorem ?
– lhf
Mar 9, 2013 at 13:41

The group theoretic proof on Wikipedia is good.

Alternatively, another nice way is, the second line is working in $$\mathbb{Z}/p\mathbb{Z}$$,

$$\frac2p\sum_{n=1}^{p-1} \frac{1}{n} = \frac2p \sum_{n=1}^{(p-1)/2} \left(\frac{1}{n} + \frac{1}{p-n}\right) = 2 \sum_{n=1}^{(p-1)/2} \frac{1}{n(p - n)}$$ $$\equiv -\sum_{n=1}^{p-1} \frac{1}{n^2} \equiv - \sum_{n=1}^{p-1} n^2 \equiv -\frac{(p-1)p(2p - 1)}{6}$$

which appears in this article by Christian Aebi and Grant Cairns.

A more hands-on approach can be found in these notes by Timothy Choi.

Finally, an excellent survey and additional results here by Romeo Mestrovic.

• I love this argument, and of course +1 upvote! Mar 9, 2013 at 15:25
• How can we show a congruence modulo $p^2$ by working in $\mathbb{Z}/p\mathbb{Z}$ ? It seems to me your computation only shows that your sum is $0$ modulo $p$. You can get that property by $\sum_{k \in \mathbb{Z}/p\mathbb{Z}^*} k^{-1} = \sum_{k \in \mathbb{Z}/p\mathbb{Z}^*} k$ and notice that $\sum_{k \in \mathbb{Z}/p\mathbb{Z}^*} k = 0$ when $p > 2$ because it is translation invariant. Jun 9, 2015 at 14:33
• It is the same answer as Mercio, the wording was inadequate May 22, 2020 at 23:50
• @JoelCohen: $x\equiv0\pmod{p}\Leftrightarrow px\equiv0\pmod{p^2}$ Apr 1, 2022 at 8:30

$(1 + \frac 1 {p-1}) + (\frac 1 2 + \frac 1 {p-2}) + \ldots + (\frac 1 {(p-1)/2} + \frac 1 {(p+1)/2}) = \frac p {p-1} + \frac p {2(p-2)} + \ldots + \frac p {((p-1)(p+1)/4)} \\ = p \sum_{k=1}^{(p-1)/2} \frac 1 {k(p-k)} = \frac p 2 \sum_{k=1}^{p-1} \frac 1 {k(p-k)}$.

Now, working on this second sum in the field $\Bbb Z / p \Bbb Z$, and assuming $p>3$ you get :

$\sum_{k=1}^{p-1} \frac 1 {k(p-k)} = - \sum_{k=1}^{p-1} \frac 1 {k^2} = - \sum_{k=1}^{p-1} k^2 = -(p-1)p(2p-1)/6 = 0$.

If you don't know the sum of the first consecutive squares formula, you can still get it with a bit more work :

Pick a number $a \neq 1$ such that $a$ is a square modulo $p$ (again assuming $p>3$). Then, $\sum k^2 (1-a) = \sum k^2 - \sum (ak^2) = \sum k^2 - \sum k^2 = 0$. Since $1-a \neq 0$, $\sum k^2 = 0$.

(when $p = 3$, $1+ \frac 1 2 = \frac 3 2$ which is not a multiple of $3^2$)

• (+1) I did essentially the same thing. The thing that knocks $p=3$ out of the running is the formula for the sum of squares, where there is a $6$ in the denominator.
– robjohn
Apr 1, 2022 at 15:54

Note that $\displaystyle \sum_{1 \le i \le p-1}\dfrac{1}{i}=\displaystyle \sum_{1 \le i \le \frac{p-1}{2}}\left ( \dfrac{1}{i}+\dfrac{1}{p-i} \right )=p \displaystyle \sum_{1 \le i \le \frac{p-1}{2}}\dfrac{1}{i(p-i)}=p \cdot \dfrac{a}{b}$. Thus, enough to show that $a \equiv 0 \mod p$ or, equivalently, that integer

$$S=\displaystyle \sum_{1 \le i \le \frac{p-1}{2}}\dfrac{(p-1)!}{i(p-i)}$$

is a multiple of $p$. Let $r_i \in \mathbb{Z}_p$ st $ir_i \equiv 1 \mod p$. Note que $r_{p-i} \equiv -r_i \mod p$. So,

$$S \equiv \displaystyle \sum_{1 \le i \le \frac{p-1}{2}}\dfrac{(p-1)!}{i(p-i)}\cdot ir_i \cdot (p-i)r_{p-i} \mod p$$ $$S \equiv \displaystyle \sum_{1 \le i \le \frac{p-1}{2}}r_i^2 \mod p$$ by Wilson's Theorem. Therefore,

$$S \equiv \displaystyle \sum_{1 \le i \le \frac{p-1}{2}}i^2 = \dfrac{p(p^2-1)}{24} \mod p$$

So, $S$ is a multiple of $p$.

I second Joel's comments. The proof given by Christian Aebi and Grant Cairns, in a sense, is misleading & harmful. Directly jumping into $$\mathbb{Z}/p\mathbb{Z}$$ without carefully observing suitability and justification is misleading and wrong. For example, when computing in $$\mathbb{Z}/p\mathbb{Z}$$, let $$p=5$$, then $$\frac{1}{2} + \frac{1}{3}\equiv 3 + 2 \equiv0,$$ but the numerator $$mod\ 25$$ is 5.

The original problem asks to prove the numerator $$mod\ p^2$$ is zero. One needs to be very careful when using $$\mathbb{Z}/p\mathbb{Z}.$$ For example, $$\frac{3}{7} + \frac{1}{13}$$'s numerator $$mod\ 17$$ is 12. But if calculating in $$\mathbb{Z}/p\mathbb{Z}$$ for $$p=17$$, one gets $$\frac{1}{7}\equiv5, \frac{1}{13}\equiv4$$ and $$\frac{3}{7} + \frac{1}{13}\equiv2$$. One can use $$\mathbb{Z}/p\mathbb{Z}$$ when handling $$\sum_{k=1}^{(p-1)/2}\frac{1}{r(p-r)}$$ is due to the guarantee of Wilson's theorem in the background, and the fact that we only care about if the modulus result is zero.