? p=3 %1 = 3 ? (p-1)! % 3 %2 = 2 ? p=17 %3 = 17 ? (p-1)! %4 = 20922789888000 ? (p-1)! % p %5 = 16
Next we assume that and prove that must be prime. Suppose not, so that is a composite number . Let be a prime divisor of . Then , so . Also,
Let's test Wilson's Theorem in PARI:
? wilson(n) = Mod((n-1)!,n) == Mod(-1,n) ? wilson(5) %9 = 1 ? wilson(10) %10 = 0 ? wilson(389) %11 = 1 ? wilson(2001) %12 = 0
Warning: In practice, this is a horribly inefficient way to check
whether or not a number is prime.