# 欧拉函数

**欧拉函数**（Euler's totient function），记作 \( \varphi(n) \) 或 \( \phi(n) \)，计算的是不超过 \( n \) 且与 \( n \) 互质的正整数个数，即 \([1, n]\) 中满足 \( \gcd(k, n) = 1 \) 的整数 \( k \) 的个数。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup> 它等于模 \( n \) 的单位乘法群的元素个数，也就是 \( \mathbb{Z}_n \) 中具有乘法逆元的剩余类的个数。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup><sup> • </sup><sup>[2](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Yet_Another_Introductory_Number_Theory_Textbook_-_Cryptology_Emphasis_%28Poritz%29/02%3A_Congruences/2.05%3A_Euler%27s__%CF%95__Function)</sup> 这个函数在欧拉模幂定理和RSA密码系统中处于核心地位。

| 关键事实 | 详情 |
|---|---|
| 定义 | \( \varphi(n) = \#\{k \in [1,n] : \gcd(k,n)=1\} \)，并约定 \( \varphi(1) = 1 \)<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup> |
| 素数幂 | \( \varphi(p) = p - 1 \)，\( \varphi(p^k) = p^k - p^{k-1} \)<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup> |
| 乘积公式 | 若 \( n = p_1^{k_1} \cdots p_m^{k_m} \)，则 \( \varphi(n) = n \prod_{i=1}^{m} (1 - 1/p_i) \)<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup> |
| 积性 | 当 \( \gcd(m,n)=1 \) 时，\( \varphi(mn) = \varphi(m)\varphi(n) \)；它是积性函数，但不是完全积性函数<sup>[3](https://crypto.stanford.edu/pbc/notes/numbertheory/mult.html)</sup> |
| 除数和 | \( \sum_{d \mid n} \varphi(d) = n \)；对 \( n = 12 \)，1、2、3、4、6、12 的欧拉函数值分别为 1、1、2、2、2、4，加起来等于 12<sup>[3](https://crypto.stanford.edu/pbc/notes/numbertheory/mult.html)</sup> |
| 计算现状 | 在不知道 \( n \) 的因数分解的情况下计算 \( \varphi(n) \)，本质上与分解 \( n \) 一样困难<sup>[4](https://zoo.cs.yale.edu/classes/cs460/numthlect.pdf)</sup> |
| 历史 | 欧拉于1763年定义；\( \phi \) 记号由高斯于1801年引入；“totient”一词由西尔维斯特于1879年使用<sup>[5](https://old.maa.org/press/periodicals/convergence/math-origins-the-totient-function)</sup> |

## 定义与最初的例子

该函数在正整数上定义为

\[ \varphi(n) = \#\{a \in [n] : \gcd(a, n) = 1\}. \]

对 \( n > 1 \)，这等同于计算 \([1, n-1]\) 中与 \( n \) 互质的整数个数，因为 \( \gcd(n, n) = n > 1 \)。约定 \( \varphi(1) = 1 \) 是为了使函数具有积性。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup><sup> • </sup><sup>[6](https://mileti.math.grinnell.edu/ComboNumber.pdf)</sup> 这个名称来自英国数学家詹姆斯·约瑟夫·西尔维斯特（James Joseph Sylvester），他于1879年引入了“totient”一词，距欧拉1763年的原始定义已过一个多世纪；高斯则于1801年引入了 \( \phi \) 记号。<sup>[5](https://old.maa.org/press/periodicals/convergence/math-origins-the-totient-function)</sup>

群论式的解读可以解释这个计数：\( \mathbb{Z}_n \) 中的元素 \( y \) 是单位，即具有乘法逆元，当且仅当 \( y \) 与 \( n \) 互质，因此 \( \varphi(n) \) 就是单位群 \( \mathbb{Z}_n^* \) 的大小。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup> 例如，\( \varphi(6) = 2 \)，因为在 \([1..6]\) 中只有 1 和 5 与 6 互质；\( \varphi(4) = 2 \)，因为 \([4]\) 中只有 1 和 3 与 4 互素。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup><sup> • </sup><sup>[6](https://mileti.math.grinnell.edu/ComboNumber.pdf)</sup>

## 乘积公式

两个特殊情形构成了通用公式的基础。对素数 \( p \)，模 \( p \) 的每个非零剩余类都是单位，所以 \( \varphi(p) = p - 1 \)。对素数幂 \( p^k \)，与 \( p^k \) 不互质的剩余类只有 \( p \) 的倍数，共有 \( p^k / p = p^{k-1} \) 个，因此 \( \varphi(p^k) = p^k - p^{k-1} \)。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup>

**积性。** 若 \( m \) 与 \( n \) 互质，中国剩余定理将 \( \mathbb{Z}_{mn}^* \) 与乘积 \( \mathbb{Z}_m^* \times \mathbb{Z}_n^* \) 等同起来，因此 \( \varphi(mn) = \varphi(m)\varphi(n) \)。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup><sup> • </sup><sup>[2](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Yet_Another_Introductory_Number_Theory_Textbook_-_Cryptology_Emphasis_%28Poritz%29/02%3A_Congruences/2.05%3A_Euler%27s__%CF%95__Function)</sup> 因此该函数在标准意义上是积性的，即对互质的 \( m, n \) 有 \( f(mn) = f(m)f(n) \)，但不是完全积性的：当 \( m \) 与 \( n \) 有公因子时，该等式不成立。<sup>[3](https://crypto.stanford.edu/pbc/notes/numbertheory/mult.html)</sup>

将素数幂情形与积性结合起来，对 \( n = p_1^{k_1} \cdots p_m^{k_m} \) 得到

\[ \varphi(n) = (p_1^{k_1} - p_1^{k_1-1}) \cdots (p_m^{k_m} - p_m^{k_m-1}) = n \left(1 - \frac{1}{p_1}\right) \cdots \left(1 - \frac{1}{p_m}\right). \]

乘积遍历整除 \( n \) 的所有不同素数，每个素数贡献一个因子 \( (1 - 1/p) \)，与指数无关。<sup>[1](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)</sup><sup> • </sup><sup>[7](https://algorithms.alexli.ca/euler-s-totient-function/)</sup>

## 恒等式与相关函数

由于 \( \varphi \) 是积性的，其除数和 \( F(n) = \sum_{d \mid n} \varphi(d) \) 也是积性的，事实上

\[ \sum_{d \mid n} \varphi(d) = n. \]

12 的因数为 1、2、3、4、6、12，它们的欧拉函数值 1、1、2、2、2、4 之和为 12。<sup>[3](https://crypto.stanford.edu/pbc/notes/numbertheory/mult.html)</sup> 这个恒等式也可以从循环群的性质推出。<sup>[3](https://crypto.stanford.edu/pbc/notes/numbertheory/mult.html)</sup>

欧拉函数与其他经典函数也有联系。它决定了第 \( n \) 个分圆多项式的次数：\( [\mathbb{Q}(\mu_n) : \mathbb{Q}] = \varphi(n) \)，其中 \( \mu_n \) 是 \( n \) 次单位根的集合。<sup>[8](https://math.ucla.edu/~sharifi/notes/algnum-ch03.html)</sup> 当 \( n \) 有原根时，原根的个数为 \( \varphi(\varphi(n)) \)。<sup>[9](https://zoo.cs.yale.edu/classes/cs467/2017f/attach/ho11.html)</sup>

## 欧拉定理与密码学

等价地说，在 \( n \) 个剩余类中，不与 \( n \) 互质的剩余类只有 \( n - \varphi(n) = p + q - 1 \) 个。<sup>[10](https://zoo.cs.yale.edu/classes/cs467/2008f/attach/ln10.html)</sup>

## 计算与复杂度

有了 \( n \) 的因数分解，乘积公式可以直接算出 \( \varphi(n) \)；试除法在 \( O(\sqrt{n}) \) 时间内分解 \( n \)，而波拉德ρ算法（Pollard's rho algorithm）的启发式运行时间约为 \( O(n^{1/4}) \)，在实践中能处理更大的输入。<sup>[7](https://algorithms.alexli.ca/euler-s-totient-function/)</sup><sup> • </sup><sup>[11](https://codeforces.com/topic/107472/en16)</sup> 一种埃拉托斯特尼筛法的变体可以一次性算出所有 \( k \le n \) 的 \( \varphi(k) \)：让每个素数扫过其倍数，并乘入因子 \( (1 - 1/p) \)。<sup>[7](https://algorithms.alexli.ca/euler-s-totient-function/)</sup>

没有因数分解，问题就完全不同了：计算 \( \varphi(n) \) 本质上与分解 \( n \) 一样困难。<sup>[4](https://zoo.cs.yale.edu/classes/cs460/numthlect.pdf)</sup> 形式化的工作确认了两个方向上的等价性。对 \( \varphi \) 值的预言机查询足以在确定性多项式时间内完全分解任意整数 \( n \)；而给定 \( \varphi(n) \)，某些显式给出的整数集合中的整数可以在确定性多项式时间内被完全分解。<sup>[12](https://doi.org/10.1090/S0025-5718-09-02262-5)</sup> 在已知 \( \varphi(N) \) 的素数幂分解这一假设下，也存在确定性分解算法。<sup>[13](https://journals.sagepub.com/doi/pdf/10.3233/FI-2020-1891)</sup> 反演该函数则是另一个问题：给定 \( n \)，在已知 \( n \) 的因数分解的情况下，找出所有满足 \( \varphi(m) = n \) 的 \( m \) 平均可在多项式时间内完成；而判定 \( \varphi(m) = n \) 是否有解则与整数分解问题相关联。<sup>[14](https://researchers.mq.edu.au/en/publications/complexity-of-inverting-the-euler-function/)</sup>

## 分布与渐近

欧拉函数的求和函数 \( \Phi(x) = \sum_{n \le x} \varphi(n) \) 按抛物线增长：\( \Phi(x) \sim \frac{3}{\pi^2} x^2 + O(x \log x) \)，其中的常数反映了互质数对的自然密度 \( 6/\pi^2 \)。瓦尔菲什（Walfisz）于1963年将误差项改进为 \( O(x (\log x)^{2/3} (\log \log x)^{4/3}) \)。<sup>[15](https://mathworld.wolfram.com/TotientSummatoryFunction.html)</sup> 求和函数的最初几个值为 1、2、4、6、10、12、18、22、28。<sup>[15](https://mathworld.wolfram.com/TotientSummatoryFunction.html)</sup>

当前的研究继续关注该函数的精细结构：\( \varphi(n) \) 在模素数剩余类中的分布，<sup>[16](https://doi.org/10.1307/mmj/20216082)</sup> \( \gcd(n, \varphi(n)) \) 的分布，<sup>[17](https://www.impan.pl/en/publishing-house/journals-and-series/acta-arithmetica/all/en/publishing-house/journals-and-series/acta-arithmetica/all/219/2/115958/the-distribution-of-mathrm-gcd-n-varphi-n)</sup> 以及迭代欧拉函数 \( \varphi_k(n) \) 分布的改进上界。<sup>[18](https://arxiv.org/abs/2506.23882)</sup>

## 历史

欧拉在论文《算术定理新证法》（*Theoremata arithmetica nova methodo demonstrata*）中引入了这个函数，该文于1758年在柏林科学院宣读，1763年发表于《彼得堡科学院新评论》（*Novi Commentarii academiae scientiarum Petropolitanae*）第8卷，第74至104页。欧拉在文中给出了费马定理的第三种证明，即如今所称的欧拉-费马定理，并证明了：当 gcd(\( x \),\( N \))=1 时，满足 \( x \)^k ≡ 1 (mod \( N \)) 的最小正整数指数 k 整除 φ(\( N \))，即 [1,\( N \)] 中与 \( N \) 互质的整数个数。<sup>[19](https://scholarlycommons.pacific.edu/euler-works/271/)</sup> \( \phi \) 记号来自高斯1801年的《算术研究》（*Disquisitiones Arithmeticae*），西尔维斯特的“totient”一词出现于1879年，距欧拉的定义已有116年。<sup>[5](https://old.maa.org/press/periodicals/convergence/math-origins-the-totient-function)</sup>

## References

1. [Units and the Totient Function, Stanford Number Theory notes (P. B. Cohen)](https://crypto.stanford.edu/pbc/notes/numbertheory/units.html)
2. [Euler's ϕ Function, Yet Another Introductory Number Theory Textbook (Poritz), LibreTexts](https://math.libretexts.org/Bookshelves/Combinatorics_and_Discrete_Mathematics/Yet_Another_Introductory_Number_Theory_Textbook_-_Cryptology_Emphasis_%28Poritz%29/02%3A_Congruences/2.05%3A_Euler%27s__%CF%95__Function)
3. [Multiplicative Functions, Stanford Number Theory notes](https://crypto.stanford.edu/pbc/notes/numbertheory/mult.html)
4. [Algorithms for integers, polynomials (T. Theobald), Yale lecture notes](https://zoo.cs.yale.edu/classes/cs460/numthlect.pdf)
5. [Math Origins: The Totient Function, Mathematical Association of America](https://old.maa.org/press/periodicals/convergence/math-origins-the-totient-function)
6. [Combinatorics and Number Theory (Mileti), Grinnell College](https://mileti.math.grinnell.edu/ComboNumber.pdf)
7. [Euler's Totient Function, Algorithms notes (A. Li)](https://algorithms.alexli.ca/euler-s-totient-function/)
8. [Algebraic Number Theory, Chapter 3 (R. Sharifi), UCLA](https://math.ucla.edu/~sharifi/notes/algnum-ch03.html)
9. [Euler function, Yale CS 467 handout](https://zoo.cs.yale.edu/classes/cs467/2017f/attach/ho11.html)
10. [Yale CS 467 lecture notes on the totient function and RSA](https://zoo.cs.yale.edu/classes/cs467/2008f/attach/ln10.html)
11. [Euler's phi function tutorial, Codeforces](https://codeforces.com/topic/107472/en16)
12. [B. Źrałek, "Reductions of factoring to computing Euler's totient function," Math. Comp. 79 (2010), 513–533](https://doi.org/10.1090/S0025-5718-09-02262-5)
13. [M. Hittmeir, J. Pomykała, "Deterministic Integer Factorization with Oracles for Euler's Totient Function," Fundamenta Informaticae (2020)](https://journals.sagepub.com/doi/pdf/10.3233/FI-2020-1891)
14. [Complexity of inverting the Euler function, Macquarie University](https://researchers.mq.edu.au/en/publications/complexity-of-inverting-the-euler-function/)
15. [Totient Summatory Function, Wolfram MathWorld](https://mathworld.wolfram.com/TotientSummatoryFunction.html)
16. [N. Lebowitz-Lockard, P. Pollack, A. Singha Roy, "Distribution mod p of Euler's Totient and the Sum of Proper Divisors," Michigan Mathematical Journal (2024)](https://doi.org/10.1307/mmj/20216082)
17. [J. Stucky, "The distribution of gcd(n, φ(n))," Acta Arithmetica 219 (2025), 169–197](https://www.impan.pl/en/publishing-house/journals-and-series/acta-arithmetica/all/en/publishing-house/journals-and-series/acta-arithmetica/all/219/2/115958/the-distribution-of-mathrm-gcd-n-varphi-n)
18. [P. Gao, Q. Yang, "An improved upper bound for the distribution of iterated Euler totient functions," arXiv:2506.23882](https://arxiv.org/abs/2506.23882)
19. [L. Euler, "Theoremata arithmetica nova methodo demonstrata" (E271), Euler Archive, University of the Pacific](https://scholarlycommons.pacific.edu/euler-works/271/)

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

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Number theory › Elementary number theory › Arithmetic functions

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/eulers-totient-function

English original: https://www.edgepedia.org/eulers-totient-function
