// 求 n 的欧拉函数
int calPhi(int n) {
int ret = n;
int bd = std::sqrt(n);
for (int i = 2; i <= n / i; ++i) {
if (n % i == 0) {
ret = ret / i * (i - 1);
while (n % i == 0) {
n /= i;
}
}
}
if (n > 1) {
ret = ret / n * (n - 1);
}
return ret % P;
}
标签:bd,函数,int,ret,模板,欧拉
From: https://www.cnblogs.com/hacker-dvd/p/17187401.html