A Wilson prime is a prime p such that (p−1)!≡−1 mod p^2. Write a procedure which determines all Wilson primes less than10^4


I try to use the for loop to solve this question, but it does not work. And here is what I did.

For(p = 2,p<=10000,(p-1)! = -1 mod (p^2),Print(p))

I am not sure how to describe "(p−1)!≡−1 mod p^2" in Mathematica. Could you give me some suggestions? Thank you.