# 2,147,483,647

**2,147,483,647** 是等于 \( 2^{31} - 1 \) 的素数，第八个梅森素数，也是计算领域中 32 位有符号二进制整数的最大正值。它的名声来自这两重身份：在数论中，它曾是十九世纪大部分时间里已知最大的素数；在软件中，它是常量 `INT32_MAX`，是 32 位有符号计数器和量值停止的天花板。

| 关键事实 | 详情 |
|---|---|
| 数值 | \( 2^{31} - 1 = 2{,}147{,}483{,}647 \)，一个 10 位素数<sup>[1](https://proofwiki.org/wiki/2%2C147%2C483%2C647)</sup> |
| 梅森素数地位 | 第八个梅森素数，排在 3、7、31、127、8191、131071 和 524287 之后<sup>[1](https://proofwiki.org/wiki/2%2C147%2C483%2C647)</sup> |
| 素性证明 | 莱昂哈德·欧拉（Leonhard Euler），不晚于 1772 年，运用推理与试除法<sup>[2](https://t5k.org/notes/by_year.html)</sup> |
| 计算中的作用 | 32 位有符号整数的最大值，`INT32_MAX`<sup>[3](https://open-std.org/jtc1/sc22/wg14/www/docs/n788.htm)</sup> |
| 相关完全数 | \( 2^{30}(2^{31} - 1) = 2305843008139952128 \)，欧拉于 1732 年证明其为完全数<sup>[4](https://mathshistory.st-andrews.ac.uk/HistTopics/Perfect_numbers/)</sup> |
| 溢出行为 | 有符号整数溢出在 C 和 C++ 中属于未定义行为<sup>[5](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2817.pdf)</sup> |

## 一个梅森素数

梅森数具有 \( 2^{p} - 1 \) 的形式；当这样的数是素数时，便称为梅森素数。\( 2^{31} - 1 \) 是这一序列中的第八个，其前几项为 3、7、31、127、8191、131071、524287 和 2147483647<sup>[1](https://proofwiki.org/wiki/2%2C147%2C483%2C647)</sup>。马兰·梅森（Marin Mersenne）在 1644 年将指数 31 列入他声称的素数指数之中，欧拉确认了这一条目是正确的<sup>[4](https://mathshistory.st-andrews.ac.uk/HistTopics/Perfect_numbers/)</sup>。

**欧拉的证明。** 欧拉早在 1732 年就把 \( 2^{31} - 1 \) 列为素数，但在 1752 年写给哥德巴赫（Goldbach）的一封信中，他对此并不确定。到 1772 年，他已经完成了证明：他证明 \( 2^{31} - 1 \) 的每个素因子必定具有 \( 248n + 1 \) 或 \( 248n + 63 \) 两种形式之一，然后除以所有小于 46339 的此类素数<sup>[2](https://t5k.org/notes/by_year.html)</sup>。界 46339 刚好低于该数的平方根，约为 46340.9，因此穷尽这些候选者便确定了素性<sup>[6](https://ctnt-summer.math.uconn.edu/wp-content/uploads/sites/1632/2018/05/mersennetalkCTNT.pdf)</sup>。

**纪录地位与完全数。** 每个梅森素数 \( 2^{p} - 1 \) 都给出偶完全数 \( 2^{p-1}(2^{p} - 1) \)，因此欧拉的素数给出了完全数 \( 2^{30}(2^{31} - 1) = 2305843008139952128 \)，他在 1732 年证明了它是完全数，这是 125 年来发现的第一个新完全数<sup>[4](https://mathshistory.st-andrews.ac.uk/HistTopics/Perfect_numbers/)</sup>。那个完全数在 150 多年间一直是已知最大的。彼得·巴洛（Peter Barlow）在其 1811 年的《数论》中写道，它很可能是人类所能发现的最大完全数，因为完全数只是引人好奇，并无用处<sup>[4](https://mathshistory.st-andrews.ac.uk/HistTopics/Perfect_numbers/)</sup>。下一个梅森素数 \( 2^{61} - 1 \) 由伊万·米赫耶维奇·佩尔武申（Ivan Mikheevich Pervushin）于 1883 年发现<sup>[7](https://www.mersenne.org/primes/)</sup>。

## 现代验证

梅森数的素性如今用卢卡斯-莱默检验（Lucas-Lehmer test）来确定，这是一种高效的确定性检验，由爱德华·卢卡斯（Édouard Lucas）的方法发展而来，并经德里克·莱默（Derrick Lehmer）于 1930 年修改<sup>[8](https://mathworld.wolfram.com/Lucas-LehmerTest.html)</sup><sup> • </sup><sup>[4](https://mathshistory.st-andrews.ac.uk/HistTopics/Perfect_numbers/)</sup>。检验从 \( s_0 = 4 \) 开始，迭代 \( s_{n} = s_{n-1}^{2} - 2 \pmod{M_p} \)；梅森数 \( M_p \) 是素数当且仅当 \( s_{p-2} \) 为零<sup>[8](https://mathworld.wolfram.com/Lucas-LehmerTest.html)</sup>。对于 \( p = 31 \)，余数为零，证实了欧拉手工建立的素性<sup>[8](https://mathworld.wolfram.com/Lucas-LehmerTest.html)</sup>。在互联网梅森素数大搜索（Great Internet Mersenne Prime Search）中，该检验仍是大型梅森素数认证背后的主要引擎<sup>[9](https://arxiv.org/abs/2608.05319)</sup>。

## 32 位有符号整数上限

C 标准将这一值定为精确宽度有符号整数类型的 `INT32_MAX`<sup>[3](https://open-std.org/jtc1/sc22/wg14/www/docs/n788.htm)</sup>，而 Swift 将有符号定宽整数类型的 `Int32.max` 记为 \( (2^{\text{bitWidth} - 1}) - 1 \)<sup>[10](https://developer.apple.com/documentation/Swift/Int32/max)</sup>。

**溢出。** 当有符号 32 位计算超出这一值时，C 和 C++ 标准将结果视为未定义行为，而不是定义回绕<sup>[5](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2817.pdf)</sup><sup> • </sup><sup>[11](https://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0105r1.html)</sup>。在 x86 硬件的实践中，该值会翻转为可表示的最负整数<sup>[12](https://www.tomshardware.com/video-games/pc-gaming/doom-left-running-on-asus-mypal-pda-for-2-5-years-finally-crashes-bug-that-crashes-the-game-when-gametic-value-hits-2-147-483-647-ticks-likely-to-blame)</sup>。

一个具体的案例来自游戏《毁灭战士》（DOOM），其引擎将游戏时钟计数器存为一个从不重置的有符号 32 位整数。一个《毁灭战士》移植版在华硕 MyPal 掌上电脑上持续运行了约 2.5 年，当时钟值达到 2,147,483,647 时崩溃。以每秒 35 个时钟计，溢出需要约 1.95 年的连续运行；若降至 30 赫兹的时钟频率，则需要约 2.26 年，这与观察到的 2.5 年相符——其中包含了错误被注意到之前的空闲时间<sup>[12](https://www.tomshardware.com/video-games/pc-gaming/doom-left-running-on-asus-mypal-pda-for-2-5-years-finally-crashes-bug-that-crashes-the-game-when-gametic-value-hits-2-147-483-647-ticks-likely-to-blame)</sup>。

## References

1. [2,147,483,647, ProofWiki](https://proofwiki.org/wiki/2%2C147%2C483%2C647)
2. [The Largest Known Prime by Year: A Brief History, Chris Caldwell, Prime Pages](https://t5k.org/notes/by_year.html)
3. [ISO/IEC JTC1/SC22/WG14 N788, limits of exact-width signed integer types](https://open-std.org/jtc1/sc22/wg14/www/docs/n788.htm)
4. [Perfect Numbers, MacTutor History of Mathematics](https://mathshistory.st-andrews.ac.uk/HistTopics/Perfect_numbers/)
5. [WG 14, N2817: Can Signed Integers Overflow? David Svoboda, 2021](https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2817.pdf)
6. [The Biggest Known Prime Number, CTNT lecture, University of Connecticut](https://ctnt-summer.math.uconn.edu/wp-content/uploads/sites/1632/2018/05/mersennetalkCTNT.pdf)
7. [List of Known Mersenne Prime Numbers, PrimeNet](https://www.mersenne.org/primes/)
8. [Lucas-Lehmer Test, Wolfram MathWorld](https://mathworld.wolfram.com/Lucas-LehmerTest.html)
9. [The sesquicentennial of the prime number 2^127 − 1, arXiv](https://arxiv.org/abs/2608.05319)
10. [Int32.max, Apple Developer Documentation](https://developer.apple.com/documentation/Swift/Int32/max)
11. [Rounding and Overflow in C++, P0105R1, WG21](https://open-std.org/JTC1/SC22/WG21/docs/papers/2017/p0105r1.html)
12. [DOOM left running on ASUS MyPal PDA for 2.5 years finally crashes, Tom's Hardware](https://www.tomshardware.com/video-games/pc-gaming/doom-left-running-on-asus-mypal-pda-for-2-5-years-finally-crashes-bug-that-crashes-the-game-when-gametic-value-hits-2-147-483-647-ticks-likely-to-blame)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Number theory › Elementary number theory › Prime numbers: elementary aspects

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/2-147-483-647

English original: https://www.edgepedia.org/2-147-483-647
