跳到正文

个人记录

筛法求欧拉函数

include13_fAKe约 1 分钟
原文
文章信息与版本

文章信息

发布
2025年1月19日
收录
2026年6月17日
更新
2026年11月14日
篇幅
约 1 分钟
获赞
2

版本

  1. v1当前

用线性筛的求法进行计算。

phi(n)={p1×phi(n′)n′mod  p1=0(p1−1)×phi(n′)Otherwise\text{phi}(n)=\left\{\begin{matrix} p_1\times \text{phi}(n') & n'\mod p_1=0\\ (p_1-1)\times \text{phi}(n') & \text{Otherwise} \end{matrix}\right.

其中 n′×p1=nn'\times p_1=n。