#include<bits/stdc++.h>
#define ll unsigned long long int
#define N 100010
using namespace std;
int p[N+1];
void prime()
{
ll i, j;
ll l = sqrt(N);
for(i=2;i<=l;i++)
{
if(p[i] == 0)
{
for(j=2;i*j<=N;j++)
{
p[i*j] = 1;
}
}
}
}
int phi[N+1];
void phifunction()
{
ll i, j;
for(i=1;i<=N;i++)
phi[i] = i;
for(i=2;i<=N;i++)
{
if(p[i] == 0)
{
for(j=i;j<=N;j+=i)
phi[j] = phi[j]/i*(i-1);
}
}
}
int main()
{
prime();
phifunction();
ll n, t, i, j;
while(cin >> t)
{
for(i=1;i<=t;i++)
{
cin >> n;
cout << phi[n] << endl;
}
}
return 0;
}
#define ll unsigned long long int
#define N 100010
using namespace std;
int p[N+1];
void prime()
{
ll i, j;
ll l = sqrt(N);
for(i=2;i<=l;i++)
{
if(p[i] == 0)
{
for(j=2;i*j<=N;j++)
{
p[i*j] = 1;
}
}
}
}
int phi[N+1];
void phifunction()
{
ll i, j;
for(i=1;i<=N;i++)
phi[i] = i;
for(i=2;i<=N;i++)
{
if(p[i] == 0)
{
for(j=i;j<=N;j+=i)
phi[j] = phi[j]/i*(i-1);
}
}
}
int main()
{
prime();
phifunction();
ll n, t, i, j;
while(cin >> t)
{
for(i=1;i<=t;i++)
{
cin >> n;
cout << phi[n] << endl;
}
}
return 0;
}
Comments
Post a Comment