#include <bits/stdc++.h> using namespace std; int eular(int n) { int res=1; for(int i=2;i*i<=n;i++){ if(n%i==0){ n/=i,res*=i-1;//保证i一定是素数 while(n%i==0) n/=i,res*=i; } } if(n>1) res*=n-1; return res; } int main() { int n; while(scanf("%d",&n)!=EOF){ printf("%d\n",eular(n)); } return 0; }
原文地址:http://blog.csdn.net/u013050857/article/details/45064005