TITLE: $\frac{1^2+2^2+\cdots+n^2}{n}$ is a perfect square
QUESTION [9 upvotes]: 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)$.

REPLY [5 votes]: 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.

REPLY [3 votes]: 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.