(-1)^j.j!^2 == -1modn, where n=2j+1 implies primality.

We can also write this as

(-1)^j.(j^2 mod n)! == -1

And so Wilson's Theorem states that n is prime iff the product of it's

quadratic residues using 1 to j is +/-1 modn.

Jon Perry

perry@...

http://www.users.globalnet.co.uk/~perry/maths/

http://www.users.globalnet.co.uk/~perry/DIVMenu/

BrainBench MVP for HTML and JavaScript

http://www.brainbench.com