Find smallest integer $n$ so that $\sqrt{\frac{1^2+2^2+3^2+...+n^2}n}$ is an integer 
Find smallest positive integer $n$ (not equal to $1$) so that $\frac{1^2+2^2+3^2+...+n^2}n$ is a perfect square.

I tried to use : $1^2+2^2+3^2+...+n^2=\frac{n(n+1)(2n+1)}6$
That gives us $\frac{1^2+2^2+3^2+...+n^2}n=\frac{(n+1)(2n+1)}6$
I tried to brute-force it using python, and I got $n=337$, but I should probably use modular arithmetic (or something else).

You want to solve
$$(n+1)(2n+1)=6m^2.$$
This is
$$16n^2+24n+8=48m^2$$
or
$$(4n+3)^2-48m^2=1.$$
This is basically Pell's equation $x^2-48y^2=1$, but with the extra
stipulation $x\equiv3\pmod 4$. The positive solutions of this
 Pell equation are given by
$$x_k+y_k\sqrt{48}=(7+\sqrt{48})^k.$$
The solutions with $x_k\equiv 3\pmod 4$ are those with $k$ odd. The
first is $x_1=7$ giving $n=1$. The next is $x_3=1351$ giving $n=337$.
The next is $x_5=262087$ giving $n=65521$, etc.
