# 威尔逊定理

**威尔逊定理**是数论中素数的一种刻画：整数 \( n > 1 \) 是素数，当且仅当 \( (n-1)! + 1 \) 能被 \( n \) 整除，等价地，\[ (n-1)! \equiv -1 \pmod{n}. \] 该定理最早由爱德华·沃林（Edward Waring）于1770年提出，他将其归功于约翰·威尔逊（John Wilson），而第一个证明由约瑟夫-路易·拉格朗日（Joseph-Louis Lagrange）给出。

| 关键事实 | 详情 |
|---|---|
| 陈述 | \( n > 1 \) 是素数，当且仅当 \( (n-1)! + 1 \equiv 0 \pmod n \)<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup> |
| 归属 | 由E. 沃林（1770）提出，归功于J. 威尔逊；由J.L. 拉格朗日证明<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup> |
| 首次证明日期 | 据《数学百科全书》为1771年；据Encyclopedia.com，拉格朗日首次发表证明的日期为1773年<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup><sup> • </sup><sup>[2](https://www.encyclopedia.com/people/literature-and-arts/english-literature-1500-1799-biographies/john-wilson)</sup> |
| 标准证明 | 将模素数下的每个剩余与其逆元配对；只有1和 \( p-1 \) 是自身的逆元，因此其余每一对都贡献一个因子1<sup>[3](https://androma.org/theorems/733)</sup> |
| 逆命题 | 合数 \( n > 4 \) 满足 \( (n-1)! \equiv 0 \pmod n \)，因此对合数该同余式不成立<sup>[4](https://calc-path.com/number-theory/modules/classical-theorems)</sup> |
| 例子 | 对 \( p = 7 \)，\( 6! = 720 \equiv -1 \pmod 7 \)<sup>[5](https://oeis.org/wiki/Wilson%27s_theorem)</sup> |
| 实际用途 | 作为素性检验并不推荐，因为阶乘会迅速变得非常大<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup> |

## 陈述与含义

该定理给出了模素数下所有非零剩余之积的值。对于素数 \( p \)，整数 \( 1, 2, \ldots, p-1 \) 的乘积模 \( p \) 同余于 \( -1 \)，因此加1便得到 \( p \) 的一个倍数<sup>[3](https://androma.org/theorems/733)</sup>。逆命题同样成立，通常也被称为威尔逊定理：若 \( N = (p-1)! + 1 \)，其中 \( p \) 为自然数，则 \( N \) 能被 \( p \) 整除当且仅当 \( p \) 是素数<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup>。

对于合数模，该同余式以一种强烈的方式不成立。若 \( n > 4 \) 为合数，则 \( (n-1)! \equiv 0 \pmod n \)，因为 \( n \) 的因子已经出现在阶乘的各项之中<sup>[4](https://calc-path.com/number-theory/modules/classical-theorems)</sup>。小情形表现不同：对 \( n = 4 \)，\( 3! = 6 \equiv 2 \pmod 4 \)，既不是 \( -1 \) 也不是0。

## 证明思路

标准证明使用模素数 \( p \) 的乘法逆元。在剩余 \( 1, 2, \ldots, p-1 \) 中，等于自身逆元的只有 \( 1 \) 和 \( p-1 \)；其余每个剩余都与一个不同的逆元配对，每一对模 \( p \) 的乘积为1<sup>[3](https://androma.org/theorems/733)</sup>。因此全乘积归结为 \( 1 \cdot (p-1) \equiv -1 \pmod p \)。\( p = 2 \) 的情形单独验证，因为 \( 1! = 1 \equiv -1 \pmod 2 \)<sup>[3](https://androma.org/theorems/733)</sup>。

对于逆命题，只需证明合数不可能满足该同余式：若 \( n \) 为合数，则它有正因子 \( a \) 满足 \( 1 < a < n \)，而该因子整除 \( (n-1)! \)，这就排除了 \( (n-1)! \equiv -1 \pmod n \)<sup>[6](https://mathcenter.oxford.emory.edu/site/math125/wilsonsConverse/)</sup>。基于不同原理的其他证明也存在；博尔克（Bolker）曾给出一个利用多项式代数与费马小定理的证明<sup>[5](https://oeis.org/wiki/Wilson%27s_theorem)</sup>。

## 历史

爱德华·沃林在其《代数沉思录》（*Meditationes Algebraicae*，1770）中发表了该陈述，并将其归功于他的前学生约翰·威尔逊，但未给出证明<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup><sup> • </sup><sup>[2](https://www.encyclopedia.com/people/literature-and-arts/english-literature-1500-1799-biographies/john-wilson)</sup>。拉格朗日提供了第一个证明。《数学百科全书》将其定年为1771年<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup>，而Encyclopedia.com则给出1773年作为首次发表证明的日期，并指出拉格朗日的论证是直接的，且可由此推出费马定理（1640），后者由欧拉于1736年首次证明<sup>[2](https://www.encyclopedia.com/people/literature-and-arts/english-literature-1500-1799-biographies/john-wilson)</sup>。

威尔逊本人并非以数学家为主要职业；他取得律师资格，并于1786年升任民事高等法院法官，后来曾短暂担任国玺专员之一<sup>[2](https://www.encyclopedia.com/people/literature-and-arts/english-literature-1500-1799-biographies/john-wilson)</sup>。

## 与费马小定理的关系

威尔逊定理是把阶乘或幂与素数联系起来的两条经典同余式之一。费马小定理说，若 \( p \) 为素数且 \( 1 \le a \le p-1 \)，则 \[ a^{p-1} \equiv 1 \pmod p. \] 其逆命题只在受限意义下成立：该同余式必须对每个 \( a \) 值都成立，才能断定 \( n \) 是素数，因为存在对一切与 \( n \) 互素的 \( a \) 都满足 \( a^{n-1} \equiv 1 \pmod n \) 的合数<sup>[7](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Elementary_Number_Theory_%28Barrus_and_Clark%29/01%253A_Chapters/1.25%253A_Primality_Tests)</sup>。相比之下，威尔逊定理是一种精确刻画：单个关于 \( (n-1)! \) 的同余式即可判定素性<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup>。这两个结果是用真正不同的论证证明的，威尔逊定理的正向通过将剩余与其逆元配对，逆向则通过分析合数 \( n \)<sup>[4](https://calc-path.com/number-theory/modules/classical-theorems)</sup>。

## 作为素性检验

由于该同余式恰好对素数成立，威尔逊定理给出了一种素性检验：自然数 \( n > 1 \) 是素数，当且仅当 \( (n-1)! + 1 \equiv 0 \pmod n \)<sup>[1](https://encyclopediaofmath.org/wiki/Wilson_theorem)</sup>。该检验在实践中并不使用。阶乘 \( (n-1)! \) 增长极快，直接计算它是指数时间问题，而将大阶乘的计算模 \( n \) 约化也并不改变这一点<sup>[8](https://math.dartmouth.edu/~carlp/PDF/pcm0049.pdf)</sup>。例如，检验 \( n = 19 \) 时，若不做模约化，已经需要计算 \( 18! \approx 6.4 \times 10^{15} \)<sup>[7](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Elementary_Number_Theory_%28Barrus_and_Clark%29/01%253A_Chapters/1.25%253A_Primality_Tests)</sup>。

该定理反而作为数论内部的工具发挥作用。它给出 \( (p-1)! \) 模 \( p \) 的值，这一值用于涉及剩余乘积的计算以及涉及阶乘的同余式<sup>[3](https://androma.org/theorems/733)</sup>。

## 模素数幂的精细化

该定理有一些扩展，描述了 \( (p-1)! \) 在模数为 \( p \) 的更高次幂时的值。格莱舍（Glaisher）1900年的公式涉及威尔逊定理模 \( p^2 \)<sup>[9](https://arxiv.org/abs/1912.06652)</sup>。相关的**威尔逊商**定义为满足 \[ (p-1)! + 1 = p \cdot W_p, \] 的整数 \( W_p \)，近期工作通过费马商的幂和的超同余式，给出了它模各个更高素数幂的表达式，并将威尔逊商的计算推进到模 \( p^4 \)<sup>[10](https://arxiv.org/abs/2509.05402)</sup>，进一步的工作则处理模 \( p^6 \) 和 \( p^7 \) 的情形<sup>[11](https://arxiv.org/abs/2510.26743)</sup>。

## References

1. [Wilson theorem, Encyclopedia of Mathematics (N.I. Klimov, originator)](https://encyclopediaofmath.org/wiki/Wilson_theorem)
2. [John Wilson, Encyclopedia.com](https://www.encyclopedia.com/people/literature-and-arts/english-literature-1500-1799-biographies/john-wilson)
3. [Wilson Theorem — Statement & Proof, Androma](https://androma.org/theorems/733)
4. [Number Theory — Classical Theorems, CalcPath](https://calc-path.com/number-theory/modules/classical-theorems)
5. [Wilson's theorem, OeisWiki](https://oeis.org/wiki/Wilson%27s_theorem)
6. [The Converse of Wilson's Theorem, Emory Math Center](https://mathcenter.oxford.emory.edu/site/math125/wilsonsConverse/)
7. [1.25: Primality Tests, Elementary Number Theory (Barrus and Clark), Mathematics LibreTexts](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Elementary_Number_Theory_%28Barrus_and_Clark%29/01%253A_Chapters/1.25%253A_Primality_Tests)
8. [Computational Number Theory, Dartmouth (C. Pomerance)](https://math.dartmouth.edu/~carlp/PDF/pcm0049.pdf)
9. [Wilson's theorem modulo p² derived from Faulhaber polynomials, arXiv:1912.06652](https://arxiv.org/abs/1912.06652)
10. [Wilson's theorem modulo higher prime powers II: Bernoulli numbers and polynomials, arXiv:2509.05402](https://arxiv.org/abs/2509.05402)
11. [Wilson's theorem modulo higher prime powers III: The cases modulo p⁶ and p⁷, arXiv:2510.26743](https://arxiv.org/abs/2510.26743)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Number theory › Elementary number theory › Congruences and modular arithmetic

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/wilsons-theorem

English original: https://www.edgepedia.org/wilsons-theorem
