威尔逊定理?当且仅当 \(p\) 为质数时,\((p-1)! \equiv -1(mod\ p)\) 。即: \(p\) 为质数 \(\Leftrightarrow (p-1)! \equiv -1(mod\ p)\) 。
威尔逊定理的证明
必要性
易得:\((p-1)!\equiv -1(mod\ p)\Leftrightarrow p|(p-1)!+1\) 。
假设 \(p\) 不是质数,\(a\) 是 \(p\) 的质因子。我们有:\(a | (p-1)!\) ,\(a \not| (p-1)!+1\) 。而由上式我们可知:\(p|(p-1)!+1 \Rightarrow a|(p-1)!+1\) 。
前后矛盾,故 \(p\) 一定为质数。
充分性
原文:https://www.cnblogs.com/solvit/p/11436753.html