#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<set>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
int phi[100005];
int n;
int t;
int sj(int x){
int res;
res=x;
for(int i=2;i*i<=n;i++){
if(x%i==0){
res*=(i-1);
res/=i;
while(x%i==0){
x/=i;
}
}
}
if(x>1){
res*=(x-1);
res/=x;
}
return res;
}
int main(){
freopen("16.in","r",stdin);
freopen("16.out","w",stdout);
scanf("%d",&n);
/*递推算法*/
for(int i=1;i<=n;i++){
phi[i]=i;
}
for(int i=2;i<=n;i+=2){
phi[i]/=2;
}
for(int i=3;i<=n;i+=2){
if(phi[i]==i){
for(int j=i;j<=n;j+=i){
phi[j]/=i;
}
}
}
printf("%d",phi[n]);
/*公式法*/
t=sj(n);
printf("%d",t);
return 0;
}
欧拉函数
最新推荐文章于 2023-05-09 18:58:44 发布