$\frac{1^2+2^2+\cdots+n^2}{n}$ is a perfect square

Prove that there exist infinitely many positive integers $n$ such that $\frac{1^2+2^2+\cdots+n^2}{n}$ is a perfect square. Obviously, $1$ is the least integer having this property. Find the next two least integers with this property.

The given condition is equivalent to $(2n+2)(2n+1) = 12p^2$ where $p$ is a positive integer. Then since $\gcd(2n+2,2n+1) = 1$, we have that $2n+2 = 4k_1$ and $2n+1 = k_2$. We must have that $k_1$ is divisible by $3$ or that $k_2$ is divisible by $3$. If $k_1$ is divisible by $3$ and $k_2$ is not, then we must have that $k_1$ is divisible by $9$ and so $2n+2 = 36m$. Then we need $3mk_2$ to be a perfect square where $k_2+1 = 36m$. Thus if $3mk_2 = r^2$, we get $m = \dfrac{1}{72}\left(\sqrt{48r^2+1}+1\right)$.

• So, $$(2n+2)(2n+1)=12p^2$$ where $(2n+2,2n+1)=1=(n+1,2n+1)$ – lab bhattacharjee Aug 7 '16 at 17:23
• Pell's equation is the heart of it. Just show that if $a+b\sqrt{48}=(7+\sqrt{48})^k$ , then $a\equiv 3\pmod 4$ when $k$ is odd, and you are done. – Thomas Andrews Aug 7 '16 at 17:27
• @labbhattacharjee How does that help? – user19405892 Aug 7 '16 at 17:31
• Then next $n=337$. – Thomas Andrews Aug 7 '16 at 17:39
• You haven't proven that $2n+1$ must be a multiple of $3$, you've just asserted it. @user19405892 – Thomas Andrews Aug 7 '16 at 17:43

From the equation $(2n+1)(2n+2) = 12p^2$, we know that there are two possibilities:

• $2n+2$ is of the form $4x^2$, $2n+1$ is of the form $3y^2$.
• $2n+2$ is of the form $12x^2$, $2n+1$ is of the form $y^2$.

This follows from $2n+1, 2n+2$ being relatively prime. Thus, solutions correspond to integer solutions of the equations $4x^2-3y^2 = 1$ and $12x^2-y^2 = 1$. We claim that the former equation has infinitely many solutions. These correspond to the solutions of $a^2-3b^2 = 1$ where $a$ is even.

The theory of Pell equations can be used to show that the solutions of $a^2-3b^2 = 1$ are given by the powers $a+b\sqrt{3} = (2+\sqrt{3})^i$ for $i\ge 0$. Even without this theory in hand, we can check directly that these give solutions: $$a^2-3b^2 = (a+b\sqrt{3})(a-b\sqrt{3}) = (2+\sqrt{3})^i(2-\sqrt{3})^i = \big[(2+\sqrt{3})(2-\sqrt{3})\big]^i = 1$$

It only remains to check that infinitely many of these solutions have $a$ as even. An easy inductive argument shows that $a$ is even precisely when $i$ is odd, so there are infinitely many solutions.

The first two nontrivial solutions are $(2+\sqrt{3})^3 = 26+15\sqrt{3}$ and $(2+\sqrt{3})^5 = 362+209\sqrt{3}$. These values of $a$ correspond to $n=337$ and $n=65521$. To check that these are indeed the smallest nontrivial solutions to $(2n+1)(2n+2)=12p^2$, there are two approaches. The first is to apply the theory of Pell equations to note that there are no solutions to $a^2-3b^2=1$ other than those given above, and that there are no solutions at all to $12x^2-y^2=1$. The second method is to check by brute force that no other values less than $65521$ yield solutions.

This can be solved by using the quadratic formula on $2n^2 + 3n + (1-6p^2)=0$ to convert to the Pell's equation $r^2 - 48p^2 = 1$. Standard techniques can be used to generate infinitely many solutions, though we need to be careful to keep only those with $r \equiv 3\pmod{4}$.

For example, we can arrive at infinitely many solutions by writing $r+p\sqrt{48} = (7+\sqrt{48})^{2k+1}$, beginning from the primitive solution $r=7, p=1$.

Here is a proof that results from that process:

If $(n,p)$ is a positive solution to $(n+1)(2n+1)=6p^2$, then $(97n+168p+72,56n+97p+42)$ is a larger solution, which we can see by computing directly:

$$((97n+168p+72) + 1)(2(97n+168p+72) + 1) - 6(56n+97p+42)^2$$ $$= (n+1)(2n+1)-6p^2$$

Beginning from the solution $(n,p)=(1,1)$, this generates infinitely many solutions by induction.

• @RossMillikan The solution is $(n,p)=(1,1)$, or equivalently $(r,p)=(7,1)$. I've clarified. – Slade Aug 7 '16 at 20:39

Using this: $$\frac{\sum_{k=1}^N k^2}{N}= \frac{1}{6} (N+1) (2 N+1)=K^2$$ the condition can be written as (as you pointed out): $$(N+1) (2 N+1)=6K^2$$ through numerical search, the last part of the problem is solved $$N=1,337,65521$$

Not really a satisfying answer i know.