#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll divisors(ll n)
{
ll l = (int)sqrt(n);
ll c = 1, i;
for(i=2;i<=l;i++)
{
if(n%i == 0)
{
if(n/i == i)
c++;
else
c+=2;
}
}
return c;
}
ll phi(ll n)
{
ll i, r = n;
for(i=2;i*i<=n;i++)
{
if(n%i == 0)
{
while(n%i == 0)
{
n = n/i;
}
r = r - r/i;
}
}
if(n > 1)
r = r - r/n;
return r;
}
int main()
{
ll n, r;
while(cin >> n)
{
ll a = phi(n);
ll x = divisors(n);
ll y = n - (a + x);
if(y<0)
cout << 0 << endl;
else
cout << y << endl;
}
return 0;
}
#define ll long long int
using namespace std;
ll divisors(ll n)
{
ll l = (int)sqrt(n);
ll c = 1, i;
for(i=2;i<=l;i++)
{
if(n%i == 0)
{
if(n/i == i)
c++;
else
c+=2;
}
}
return c;
}
ll phi(ll n)
{
ll i, r = n;
for(i=2;i*i<=n;i++)
{
if(n%i == 0)
{
while(n%i == 0)
{
n = n/i;
}
r = r - r/i;
}
}
if(n > 1)
r = r - r/n;
return r;
}
int main()
{
ll n, r;
while(cin >> n)
{
ll a = phi(n);
ll x = divisors(n);
ll y = n - (a + x);
if(y<0)
cout << 0 << endl;
else
cout << y << endl;
}
return 0;
}
Comments
Post a Comment