Number Theory: $p!+p=n^2$, $p$ = prime

Find all prime numbers $p$ such that $p!+p$ is a perfect square.

I think the only ones are when $p!+p=p^2$, i.e. $p\in \{2,3\}$.

Any ideas at all?


First let $p>3$ and now for all primes $q<p$ we've $(\frac{p}{q})=1$. Now as $(\frac{q}{p})(\frac{p}{q})=(-1)^{\frac{p-1}{2}\frac{q-1}{2}}$ and $p \equiv 1 \pmod 4$ so, $(\frac{q}{p})=1$ for all primes $q<p$ and that implies $(\frac{n}{p})=1$ for all $n<p$ but that's the contradiction since there is $\frac{p-1}{2}$ non residues. So $p=3$


Note that for a small prime $q\lt p$ we have that $r=(p-1)!+1\equiv 1 \bmod q$

We have, by Wilson's Theorem that $pr=p^2s$ for some integer $s$. Now we are given that $s$ is a square and we know that $r$ is a quadratic residue $\bmod q$ (it is equivalent to the square $1$).

Since residue $\times$ residue = residue, and non-residue $\times$ residue = non-residue, it follows that $p$ must be a quadratic residue $\bmod q$ for every prime $q\lt p$.


This is not a complete answer, but it reduces the question to something significantly easier to investigate.