✔ 最佳答案
This is a Wilson's theorem
In mathematics, Wilson's theorem (also known as Al-Haytham's theorem) states that p > 1 is a prime number if and only if
圖片參考:
http://upload.wikimedia.org/math/8/c/5/8c5bdadaa5565373016c67d56c06f755.png
(see factorial and modular arithmetic for the notation).
Proof
This proof uses the fact that if p is an odd prime, then the set of numbers G = (Z/pZ)× = {1, 2, ... p − 1} forms a group under multiplication modulo p. This means that for each element a in G, there is a unique inverse element b in G such that ab ≡ 1 (mod p). If a ≡ b (mod p), then a2 ≡ 1 (mod p), which forces a2 − 1 = (a + 1)(a − 1) ≡ 0 (mod p), and since p is prime, this forces a ≡ 1 or −1 (mod p), i.e. a = 1 or a = p − 1.
In other words, 1 and p − 1 are each their own inverse, but every other element of G has a distinct inverse, and so if we collect the elements of G pairwise in this fashion and multiply them all together, we get the product −1. For example, if p = 11, we have
圖片參考:
http://upload.wikimedia.org/math/5/7/2/572602149c4eae11d12bc1a3c5f18ee5.png
If p = 2, the result is trivial to check.
For a converse ,suppose the congruence holds for a composite n, and note that then n has a proper divisor d with 1 < d < n. Clearly, d divides (n − 1)! But by the congruence, d also divides (n − 1)! + 1, so that d divides 1, a contradiction.