# What is the smallest integer $n>1$ for which the mean of the square numbers $1^2,2^2 \dots,n^2$ is a perfect square?

What is the smallest integer $$n>1$$ for which the mean of the square numbers $$1^2,2^2 \dots,n^2$$ is a perfect square?

Initially, this seemed like one could work it out with $$AM-GM$$, but it doesn't seem so.

From $$AM-GM$$ one gets that $$\frac{1^2+2^2+ \dots+n^2}{n} \geqslant \sqrt[\leftroot{-1}\uproot{2}n]{1^2\cdot2^2\dots\cdot n^2}$$

is this of any help here?

Remark. Thanks to Favst, the source of the problem is Problem 1 of 1994 British Mathematical Olympiad Round 2

• No., AM-GM seems completely useless here. As a hint... you can simplify $\sum\limits_{k=1}^n k^2$. If you don't know how, see here, but I encourage you to try to find it on your own if you can. Jul 23, 2020 at 15:42
• Does this answer your question? Number Theory and Square Number Problem Jul 23, 2020 at 16:05

The mean of the squares $$1^2, \ldots, n^2$$ is $$f(n) = \frac{1}{n} \sum_{i=1}^n i^2 = \frac{2n^2+3n+1}{6}$$ It is an integer if and only if $$n \equiv 1$$ or $$5 \mod 6$$. The first $$n > 1$$ for which it is a square is $$337$$, where $$f(337) = 38025 = 195^2$$. There are infinitely many. See OEIS sequence A084231.

This question has already been posted on this website. See my solution via Pell's equation here, where I wrote that the answer is $$337.$$ The problem appeared on the 1994 British Mathematical Olympiad Round 2

Edit: as suggested by Batominovski, I am copying my old solution here:

A while ago, I found this problem as the 1994 British Mathematical Olympiad - Round 2, Problem 1, but the solution is mine. Here it is.

The equation is $$m^2=\frac{1}{n}\sum_{k=1}^{n}{k^2}=\frac{1}{n}\cdot \frac{n(n+1)(2n+1)}{6}=\frac{(n+1)(2n+1)}{6}.$$

With some manipulation, this is equivalent to $$(4n+3)^2-48m^2=1,$$ which can be solved by Pell's equation. The fundamental solution for $$D=48$$ in Pell's equation $$x^2-Dy^2=1$$ is $$(x,y)=(7,1),$$ so all solutions are parameterized by $$x_t + y_t \sqrt{48}=(7+\sqrt{48})^t.$$ We want to find the first solution $$t>1$$ for which $$x_t\equiv 3\pmod{4}.$$ While $$t=2$$ does not work, $$t=3$$ yields $$1351+195\sqrt{48}.$$ Since $$1351=337\cdot 4+3,$$ the answer is $$337.$$

We can check that $$\frac{(337+1)(2\cdot 337+1)}{6}=3^2\cdot 5^2\cdot 13^2.$$

• I suggest that you copy your solution here. It is likely that the old thread will be deleted. Your answer should be preserved here. I think this one has a better chance of surviving deletion because the OP show some work. Jul 23, 2020 at 16:20
• @Batominovski sure, I've pasted it above here now. Jul 23, 2020 at 16:43

Hint

Start from $$1^2+2^2+\cdots +n^2={n(n+1)(2n+1)\over 6}$$

Note that the number $${1^2+2^2+\cdots +n^2\over n}$$ becomes a non-integer rational, so perfect squares can mean to be square of a quotient.

Remark

As @Batominovsky stated, the noted number cannot be a non-integer perfect square as no elimination of prime factors of $$6$$ can lead to a perfect square in the denominator.

• If this number $\dfrac{1^2+2^2+\ldots+n^2}{n}=\dfrac{(n+1)(2n+1)}{6}$ is to be a perfect square, it can only be a perfect square of an integer. This is because the denominator $6$ is squarefree. Jul 23, 2020 at 15:47
• Nice catch @Batominovski ! Jul 23, 2020 at 15:47

Following a hint by Mostafa Ayaz, we have $$(n+1)(2n+1)=6k^2$$ for some integer $$k$$. That is, $$(4n+3)^2-3(4k)^2=1\,.$$ Hence, $$(4n+3)+(4k)\sqrt{3}=(2+\sqrt{3})^m$$ for some nonnegative integer $$m$$. Therefore, $$4n+3=\sum_{r=0}^{\left\lfloor\frac{m}{2}\right\rfloor}\,\binom{m}{2r}\,2^{m-2r}\,3^r\,.$$ If $$m$$ is odd, then $$4n+3\equiv 2m\cdot 3^{\frac{m-1}{2}}\pmod{4}\,.$$ If $$m$$ is even, then $$4n+3\equiv 3^{\frac{m}{2}}\pmod{4}\,.$$ Since $$4n+3\equiv 3\pmod{4},$$ we need $$m\equiv 2\pmod{4}\,.$$
That is, $$m=4s+2$$ for some nonnegative integer $$s$$ $$4n+3+(4k)\sqrt{3}=(7+4\sqrt{3})\,(97+56\sqrt{3})^s\,.$$ That is, $$n=a_s$$ and $$k=b_s$$, where $$a_s:=\frac{(7-4\sqrt{3})\,(97+56\sqrt{3})^s+(7-4\sqrt{3})\,(97-56\sqrt{3})^s-6}{8}$$ and $$b_s:=\frac{(7-4\sqrt{3})\,(97+56\sqrt{3})^s-(7-4\sqrt{3})\,(97-56\sqrt{3})^s}{8\sqrt{3}}\,.$$ Note that $$a_0=1$$, $$a_1=337$$, and $$a_s=194\,a_{s-1}-a_{s-2}+144\text{ for }s=2,3,4,\ldots\,.$$ Furthermore, $$b_0=1$$, $$b_1=195$$, and $$b_s=194\,b_{s-1}-b_{s-2}\text{ for }s=2,3,4,\ldots\,.$$ Therefore, the next smallest pair $$(n,k)$$ apart from the one given by Robert Israel is $$(n,k)=(a_2,b_2)=(65521,37829)\,.$$