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


with javascript_semantics
constant limit = 11000
include mpfr.e
mpz f = mpz_init()
sequence primes = get_primes_le(limit),
         facts = mpz_inits(limit,1) -- (nb 0!==1!, same slot)
for i=2 to limit do mpz_mul_si(facts[i],facts[i-1],i) end for
integer sgn = 1
printf(1," n:  Wilson primes\n")
printf(1,"--------------------\n")
for n=1 to 11 do
    printf(1,"%2d:  ", n)
    sgn = -sgn
    for i=1 to length(primes) do
        integer p = primes[i]
        if p>=n then
            mpz_mul(f,facts[max(n-1,1)],facts[max(p-n,1)])
            mpz_sub_si(f,f,sgn)
            if mpz_divisible_ui_p(f,p*p) then
                printf(1,"%d ", p)
            end if
        end if
    end for
    printf(1,"\n")
end for
