Definition
A Wilson prime of order n is a prime number   p   such that   p2   exactly divides:

     (n − 1)! × (p − n)! − (− 1)n 



If   n   is   1,   the latter formula reduces to the more familiar:   (p - n)! + 1   where the only known examples for   p   are   5,   13,   and   563.



Task
Calculate and show on this page the Wilson primes, if any, for orders n = 1 to 11 inclusive and for primes p < 18   or,

if your language supports big integers, for p < 11,000.



Related task
 Primality by Wilson's theorem


using Primes
 
function wilsonprimes(limit = 11000)
    sgn, facts = 1, accumulate(*, 1:limit, init = big"1")
    println(" n:  Wilson primes\n--------------------")
    for n in 1:11
        print(lpad(n, 2), ":  ")
        sgn = -sgn
        for p in primes(limit)
            if p > n && (facts[n < 2 ? 1 : n - 1] * facts[p - n] - sgn) % p^2 == 0
                print("$p ")
            end
        end
        println()
    end
end
 
wilsonprimes()
 