POJ 2407 (欧拉函数)
直接套欧拉函数模板,链接:欧拉函数
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define fo freopen("in.txt","r",stdin)
#define fc fclose(stdin)
#define fu0(i,n) for(i=0;i<n;i++)
#define fu1(i,n) for(i=1;i<=n;i++)
#define fd0(i,n) for(i=n-1;i>=0;i--)
#define fd1(i,n) for(i=n;i>0;i--)
#define mst(a,b) memset(a,b,sizeof(a))
#define sd(n) scanf("%d",&n)
#define sdd(n,m) scanf("%d %d",&n,&m)
#define ss(s) scanf("%s",s)
#define sddd(n,m,k) scanf("%d %d %d",&n,&m,&k)
#define pans(ans) printf("%d\n",ans)
#define all(a) a.begin(),a.end()
#define sc(c) scanf("%c",&c)
#define we(a) while(scanf("%d",&a)!=EOF)
const int maxn=50000;
const double eps=1e-8;
const double PI = acos(-1.0);
ll prime[maxn],check[maxn],tot=0;
ll n;
long long phi(long long x)
{
int res = x,a = x;
for(int i=2;i*i<=a;i++)
{
if(a%i==0)
{
res = res/i*(i-1);//res -= res/i;
while(a%i==0)a/=i;
}
}
if(a>1)res =res/a*(a-1);//res -= res/a;
return res;
}
int main()
{
prepare();
while(cin>>n&&n)
{
cout<<phi(n)<<endl;
}
return 0;
}