# Find two odd primes for which $(p-1)!≡-1\mod p^2$ where $p \le13$?

Except brute force is there some way to solve this ? One way we can solve it by using Wilson's theorem but I was not able to proceed much.

• There are only $5$ primes to check...I think brute force really is the way to go. – lulu Feb 10 at 16:57
• Note: a quick search through the first 200 odd primes found only one example in addition to these two $≤13$. – lulu Feb 10 at 17:05
• In the case, someone is interested, the next solution is $563$ and there is no further solution upto $10^5$. Googling "wilson prime" reveals that no further solution is known. – Peter Feb 10 at 17:10
• Wilson's theorem is not helpful if we restrict to the primes anyway. Every prime satisfies $$(p-1)! \equiv -1\mod p$$ but only very few primes satisfy this stronger congruence. – Peter Feb 10 at 17:13
• Wikipedia says no other solutions up to $2 \times 10^{13}$ – J. W. Tanner Feb 10 at 17:21

There are only $$5$$ odd primes $$p$$ with $$p\leq13$$. Computing $$(p-1)!\pmod{p^2}$$ for each of them can hardly be called brute force; I don't need pen and paper to check that $$2!\not\equiv-1\pmod{9},\qquad 4!\equiv-1\pmod{25},\qquad 6!\not\equiv-1\pmod{49},$$ and the phrasing of the question suggests that at least one of $$p=11$$ or $$p=13$$ satisfies the congruence, so it suffices to compute $$10!\pmod{121}$$.
• $10!\equiv (2×3×4×5)×(6×8×10)×(7×9)\equiv (-1)×(-4)×(63)\equiv 252\equiv 10\bmod 121$, no good. – Oscar Lanzi Feb 10 at 17:33
• @OscarLanzi Thanks for checking, I couldn't be bothered. The phrasing of the question then implies that $(13-1)!\equiv-1\pmod{13^2}$, which I also can't be bothered to check. – Servaes Feb 10 at 17:44