Find all primes for which $p^p - 2$ is a perfect square

Find all primes for which $p^p - 2$ is a perfect square. Let $p^p-2=a^2.$

We know $a^2 \equiv 0,1\pmod{3}$

If $a^2 \equiv 1\pmod{3}$, then $p^p \equiv 0\pmod{3}\implies p=3$ which is a solution.

Now, if $a^2 \equiv 0 \pmod{3},$ then $p^p \equiv 2\pmod{3}$.

By Fermat's theorem, $p^p \equiv p \pmod{3}$ as $p$ is coprime to $3$.

So, we have $p$ is of the form $3k+2.$

But what to do next?


Solution 1:

Notice that for $p\neq 3$ must be $p=9k+t$ where $t\in\{1,2,4,5,7,8\}$ we must also have that $p=6n+1$ or $p=6n+5$ since $p\neq 2,3$.

Now by Euler theorem $t^6=1\pmod{9}$ if $p=6n+1$ we have that $$(9k+t)^{6n+1}\equiv t\pmod{9}$$ since the only $t$ such that $t-2$ is a quadratic residue mod $9$ is $t=2$ we must have $t=2$ but $6n+1\neq 9k+2$ hence no solutions.

If $p=6n+5$ we have that $$(9k+t)^{6n+5}\equiv t^5\pmod{9}$$ The only $t$ such that $t-2$ is a quadratic residue mod $9$ is $t=5$ so $p=9k+5$ this implies that the number is of the form $p=18q+5$ but again by euler theorem $$(18q+5)^{18q+5}$$ Looking mod $4$ we see that $q$ must be even so $(36q+5)^{36q+5}$ Now looking mod $108$ and using Euler we have that $$(36q+5)^{36q+5}\equiv (36q+5)^5\equiv 65,29,101\pmod{108}$$ But $x^2+2\not \equiv 65,29,101\pmod{108}$ or differently $x^2\not\equiv 63,27,99$