BMO2 1994 Q1 - Need Help Find the first number such that the average of the sum of the squares from $1$ to $n$ (where $n > 1$) equals $k^2$.
Here is what I have done so far:
The sentence is equivalent to saying that $\frac{\sum_{r=1}^{n}r^2}{n} = k^2$. Knowing the sum of the squares formula, the average of the sum of the squares is $\frac{(n+1)(2n+1)}{6}$. Equating it to $k^2$ and simplifying leads to $2n^2 + 3n + 1 = 6k^2$. This is where I am stuck at. I have tried everything in regards to algebraic tricks and manipulation. Does anybody know any methods or techniques from https://archive.ukmt.org.uk/docs/BMO%20Preparation%20Sheet.pdf that would help?

Even tough the other answer provided is far more elegant, I would like to show another possible approach:
First of all, we need $\frac{(n+1)(2n+1)}{6}$ to be an integer, and checking the possibilities modulo $2$ and $3$ we get that $n$ must be of the form $6a\pm 1$. However, if $n$ were of the form $6a-1$, plugging it in gets us $k^2=a(12a-1)$. Now since $a$ and $12a-1$ don't share any common factors, in order for their product to be a perfect square they both need to be perfect squares, but $12a-1=c^2$ doesn't have solutions modulo $3$, so $n=6a+1$.
Plugging in we have $(3a+1)(4a+1)=k^2$, and again since $3a+1$ and $4a+1$ don't share any common divisors, they both need to be perfect squares, so set $x^2=4a+1$ and $y^2=3a+1$. Substituting gets you to $3x^2=4y^2-1=(2y-1)(2y+1)$. Once again, we notice that $2y-1$ and $2y+1$ don't have common factors,so this means that there exist integers $p,q$ such that $x=pq$, $gcd(p,q)=1$, and $p^2|(2y+1)$, $q^2|(2y-1)$. So now we have two possibilities:
Case 1: $2y+1=p^2, 2y-1=3q^2$. Subtracting the two equations gives $p^2-3q=2$, which has no solution modulo $3$.
Case 2: $2y+1=3p^2$, $2y-1=q^2$, subtracting we get $3p^2-q^2=2$, and you can easily see that the smallest possible solution is $(p,q)=(3,5)$, and substituting back gives as finally $x=15$, so $a=56$ and $n=337$.
