is sometimes useful (especially in various Mathematics exam
Theorem. Let p be a prime number. Then (p-1)! = -1 (modulo p).
usually takes one of many similar forms; it's quite simple
, but surprising the first few times you see it.
"Recall" that the integers modulo some prime number p form a field. If p=2, the theorem is true ((1-1)! = 1 = -1 modulo 2).
If p is an odd prime, then 1 != -1 (modulo p). Thus these are the only two solutions of the equation x2=1 modulo p. (p-1)! modulo p is the product of all non-zero elements of the integers modulo p. So every element a apart from 1 and -1 is also multiplied by its inverse; the product is 1. Thus the product (modulo p) is exactly -1 (since -1 is not multiplied by its inverse!). QED