Let $p$ be a prime number. Show that $p^p-(p-1)^{p-1}$ can't be a square.

In other words, there is no $n\in\mathbb{N}^{+}$ such that $$p^p-(p-1)^{p-1}=n^2.$$


Let $p=2m+1$. Then $p^p=((p-1)^m+ni)((p-1)^m-ni)$. Now, the prime factorization in the Gaussian integers is unique and no factor on the right is divisible by $p$, so the only logically possible case is $p=4k+1=x^2+y^2$ and $(p-1)^m+ni=(x+iy)^p$. Then $1\equiv (p-1)^m\equiv x^p\equiv x\mod p$, so $x=1$. However, in this case the real part on the LHS is divisible by $y$ and the real part on the RHS is congruent to $1$ modulo $y$, which is a clear contradiction.


$p=2$ gives $p^p-(p-1)^{p-1}=3$, which is not a square. All other primes are congruent to either $1$ or $3$, modulo $4$. I can prove that no $p$ of the latter type satisfies the given equation.

Take $p^p-(p-1)^{p-1}$ modulo $p$; we get $0-(-1)^{p-1}=-1$. Hence a solution can exist only if $-1$ is a square modulo $p$. This happens when the Legendre symbol $(\frac{-1}{p})=1$, but for $p\equiv 3\pmod{4}$, that is not the case, by one of the parts of the Law of Quadratic Reciprocity.