# Can the sum of the first $n$ positive integers ever be the square of a prime?

I haven't been able to answer this question. Here's what I have so far ...

The sum of the first $n$ consecutive positive integers can be represented algebraically using the formula for the sum of an arithmetic series:

$$S_n = \frac{1}{2}n(2a + (n-1)d)$$

In this case $a = 1$ and $d = 1$, so this reduces to:

$$S_n = \frac{1}{2}n(n + 1)$$

So my question becomes, is there an $n$ such that:

$$\frac{1}{2}n(n + 1) = p^2$$

where $p$ is prime?

I re-arranged this to: $$n^2 + n -2p^2 = 0$$

and tried to see if the quadratic equation would help but I didn't get very far.

Am I on the right track? Any better ideas?

$n$ and $n+1$ are coprime numbers, hence if their product equals $2p^2$ either they are $1$ and $2p^2$ or $2$ and $p^2$ (there are no other ways for writing $2p^2$ as the product of two coprime integers), but both chances do not lead to solutions.
Hint: We have $\gcd(n,n+1)=1$ for any natural number $n$. Now look at the factorizations of both sides of $$n(n+1)=2p^2$$
If $n$ is even then $p$ divides $n/2$ or $n+1$. These numbers are coprime, so $p$ does not divide both. Since $n/2(n+1)=p^2$ and $n/2<n+1$, then $n/2=1$ and $n+1=p^2$, but this implies $n=2$ and $p^2=3$. It is not possible.
Similarly, if $n$ is odd then $p$ divides $n$ or $(n+1)/2$. These numbers are also coprime, so $p$ divides only one of them. $n\le(n+1)/2$ implies $n\le 1$ and $n(n+1)=2$. Otherwise, $n>(n+1)/2$, so $p^2=n$ and $(n+1)/2=1$, which leads to a contradiction, too.