When is $2^2+...+n^2=p^k$. Find all $n>1$ such that $$\sum_{i=2}^ni^2=p^k$$
where $p$ is a prime and $k\ge 1$.
I tried to use the formula for the sum of the first $n$ perfect squares, $$\frac{n(n+1)(2n+1)-6}{6}=p^k$$
$$(n-1)(2n^2+5n+6)=6p^k$$
Furthermore $d=\gcd(n-1,2n^2+5n+6)=13$ or $1$.
Let’s see when is equal $1$, we get these subcases $$\cases{n-1=1 \\ 2n^2+5n+6=6p^k}, \cases{n-1=2\\ 2n^2+5n+6=3p^k}, \cases{n-1=3\\ 2n^2+5n+6=2p^k} $$
$${\cases{n-1=6\\ 2n^2+5n+6=p^k}}$$
There are some restrictions on $p$ in the last $3$ subcases, but they’re obvious. from these cases we get these solutions $$(p,q)\in\{(2,2),(13,1),(29,1),(139,1)\} $$
But the problem lies in the case when $d=13$, I can’t get a handle on the subcases.
 A: If $d=1$, then you've done the computation correctly.
If $d = 13$, then note that $p=13$ is forced, so dividing by $13^2$ on both sides,
$$
\frac{(n-1)}{13}\frac{(2n^2+5n+6)}{13}  = 6 \times 13^{k-2}
$$
Since the quantities on the left are co-prime, we get that one of  $\frac{n-1}{13}$ or $\frac{2n^2+5n+6}{13}$ is a divisor of $6$, and the other is a multiple of $13^{k-2}$. However, for $n \geq 5$, $$2n^2+5n+6 \geq 2\times 5^2+5 \times 5 +6 \geq 81 > 78 = 13 \times 6$$
Therefore, $\frac{2n^2+5n+6}{13}$ can be a divisor of $6$ only if $n<5$. In this case, however, $\frac{n-1}{13}$ isn't even an integer (we want $n \geq 2$ so $n=1$ is ruled out).
It follows that $\frac{n-1}{13}$ must be a divisor of $6$ i.e. that $n-1 = 13,26,39,78$ i.e. that $n= 14,27,40,79$.

We will diverge from the approach in the AoPS post here, to show a different method. Indeed, one can substitute the values above and check that no more solutions are found , but we can do something that minimizes numerical computation.
We've already seen that $\frac{2n^2+5n+6}{13}>6$ for $n>5$. So if this expression is to be a multiple of a power of $13$ times a divisor of $6$ ,that power of $13$ must be at least $13$. Therefore, $2n^2+5n+6$ must be a multiple of $169$.
The idea now is to use the fact that we only need to test numbers belonging to the arithmetic progression $13k+1$. So we compute the following polynomial modulo $169$:
$$
2(1+13k)^2 + 5(1+13k)+6 \pmod{169} = 2(26k+1)+65k+5+6 = 13(9k+1)
$$
Therefore, we need $9k+1$ to be a multiple of $13$ : this doesn't occur for $k=1,2,3,6$. So no more solutions exist.
