# How to prove $\sum_{k=1}^{p-1}\frac{2^k}{k^2}\equiv-\frac{(2^{p-1}-1)^2}{p^2}\pmod p$

Let prime number $p\ge 5$,show that $$\left(\dfrac{2}{1^2}+\dfrac{2^2}{2^2}+\cdots+\dfrac{2^{p-1}}{(p-1)^2}\right)\equiv -\left(\dfrac{2^{p-1}-1}{p}\right)^2\pmod p$$

I want use Wolstenholme's theorem $$\sum_{k=1}^{p-1}\dfrac{1}{k}\equiv 0\pmod {p^2}$$ and $$\binom{p-1}{i}\equiv (-1)^i\pmod p$$ But failed

• What makes you think the congruence is correct? Did you see it somewhere? Where? – Gerry Myerson Oct 27 '16 at 6:13
• I recommend checking this for $p=5$. – user26872 Oct 27 '16 at 21:46
• @Anatoly $1/k$ denotes the inverse of $k$ modulo $p$, as it usually is in modular-arithmetic. – Cave Johnson Oct 28 '16 at 8:52
• For $p=5$, the left hand side is $44/9$ and the right hand side is $-9$. The difference is $125/9$, so the congruence actually holds modulo $p^3$ for $p=5$. – Julian Rosen Oct 28 '16 at 13:32
• @JulianRosen: Oops. Must have been getting late. – user26872 Nov 4 '16 at 1:40

There must be a shorter way to do this.

Claim 1: For $p\geq 3$, $$\frac{2^{p-1}-1}{p}\equiv -\frac{1}{2}\sum_{n=1}^{p-1}\frac{(-1)^n}{n}+\frac{p}{2}\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^n}{n\cdot m}\mod p^2.$$

Proof: \begin{align*} \frac{2^{p-1}-1}{p}&=\frac{1}{2p}\sum_{n=1}^{p-1}{p\choose n}\\ &=\frac{1}{2p}\sum_{n=1}^{p-1}\frac{p}{n}\left (\frac{p-1}{1}\cdots\frac{p-(n-1)}{n-1}\right)\\ &= -\frac{1}{2}\sum_{n=1}^{p-1}\frac{(-1) ^n}{n}\left(1-\frac{p}{1}\right)\cdots \left(1-\frac{p}{n-1}\right)\\ &\equiv -\frac{1}{2}\sum_{n=1}^{p-1}\frac{(-1)^n}{n}+\frac{p}{2}\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^n}{n\cdot m}\mod p^2. \end{align*} Claim 2: For $p\geq 3$, $$\left(\frac{2^{p-1}-1}{p}\right)^2\equiv \sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^{n+m}}{n\cdot m}\mod p.$$

Proof: Reduce Claim 1 modulo $p$ and square both sides to obtain \begin{align*} \left(\frac{2^{p-1}-1}{p}\right)^2&\equiv \frac{1}{4}\sum_{n,m=1}^{p-1}\frac{(-1)^{n+m}}{n\cdot m}\mod p\\ &=\frac{1}{2}\sum_{p-1\geq n>m\geq 1}\frac{(-1)^{n+m}}{n\cdot m}+\frac{1}{4}\sum_{n=1}^{p-1}\frac{1}{n^2}\\ &\equiv \frac{1}{2}\sum_{p-1\geq n>m\geq 1}\frac{(-1)^{n+m}}{n\cdot m}\mod p.\\ \end{align*}

Claim 3: For $p\geq 5$, $$\sum_{n=1}^{p-1}\frac{2^n}{n^2}\equiv -\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^n}{n\cdot m}\mod p.$$ First, observe that \begin{align*} 1+\frac{1}{3}+\frac{1}{5}+\ldots+\frac{1}{p}&= \frac{1}{2}\int_{-1}^1\left(1+x+x^2+\ldots+x^{p- 1}\right)\,dx\\ &=\frac{1}{2}\int_{-1}^1\frac{x^p-1}{x-1}\,dx\\ &=\frac{1}{2}\int_0^2\frac{(1-x)^p-1}{x}\,dx\\ &=\frac{1}{2}\sum_{n=1}^p {p\choose n}\frac{(-2)^n}{n}\\ &=\frac{2^{p-1}}{p}+\frac{1}{2}\sum_{n=1}^{p-1}\frac{p\cdot (-2)^n}{n^2} \left (\frac{p-1}{1}\cdots\frac{p-(n-1)}{n-1}\right).\\ \end{align*} It follows that \begin{gather*} 1+\frac{1}{3}+\ldots+\frac{1}{p-2}\equiv \frac{2^{p-1}-1}{p}-\frac{p}{2}\sum_{n=1}^{p-1}\frac{2^n}{n^2}\mod p^2,\\ \frac{1}{2}\left(\sum_{n=1}^{p-1}\frac{1}{n}-\sum_{n=1}^{p-1}\frac{(-1)^n}{n}\right)\equiv -\frac{1}{2}\sum_{n=1}^{p-1}\frac{(-1)^n}{n}+\frac{p}{2}\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^n}{n\cdot m}-\frac{p}{2}\sum_{n=1}^{p-1}\frac{2^n}{n^2}\mod p^2,\\ \sum_{n=1}^{p-1}\frac{2^n}{n^2}\equiv \sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^n}{n\cdot m}\mod p. \end{gather*} We used Wolstenholme's congruence on the last line.

Claim 4: For $p\geq 3$, $$\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^{n+m}}{n\cdot m}\equiv 2\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^{n}}{n\cdot m}\mod p.$$ Proof: Let $A_p$ be the coefficient of $x^{p-1}$ in the power series expansion of $$\frac{\log(1+x)^2}{1-x}.$$ We compute $A_p$ in two different ways. First: \begin{align*} A_p&=\sum_{m=1}^{p-1}\sum_{n=1}^{p-1-m}\frac{(-1)^{n+m}}{n\cdot m}\\ &=-\sum_{m=1}^{p-1}\sum_{n=m+1}^{p-1}\frac{(-1)^{n+m}}{(p-n)\cdot m}\\ &\equiv \sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^{n+m}}{n\cdot m}\mod p. \end{align*} Second, we have \begin{align*} \frac{\log(1+x)^2}{1-x}&=\frac{1}{1-x}\left(\int_0^x\frac{dt}{1+t}\right)^2\\ &=\frac{2}{1-x}\int_0^x\left(\int_0^y\frac{dt}{1+t}\right)\frac{dy}{1+y}\\ &=\frac{2}{1-x}\int_0^x\frac{\sum_{m\geq 1}(-1)^{m-1}\frac{y^m}{m}}{1+y}dy\\ &=\frac{2}{1-x}\int_0^x\left(\sum_{n=1}^{\infty}\sum_{m=1}^{n}\frac{(-1)^{n-1}}{m} y^n\right)dy\\ &=\frac{2}{1-x}\sum_{n=1}^{\infty} \sum_{m=1}^n\frac{(-1)^{n-1}}{m\cdot(n+1)}x^{n+1}.\\ \end{align*} It follows that $$A_p=2\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^{n}}{n\cdot m}.$$

Proof of the desired congruence: \begin{align*} -\left(\frac{2^{p-1}-1}{p}\right)^2&\equiv -\frac{1}{2}\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^{n+m}}{n\cdot m}\\ &\equiv-\sum_{n=1}^{p-1}\sum_{m=1}^{n-1}\frac{(-1)^{n}}{n\cdot m}\\ &\equiv \sum_{n=1}^{p-1}\frac{2^n}{n^2}\mod p, \end{align*} where the first line is Claim 2, the second line is Claim 4, and the third line is Claim 3.