Cod sursa(job #188208)
Utilizator | Data | 7 mai 2008 08:11:09 | |
---|---|---|---|
Problema | Fractii | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.48 kb |
#include<stdio.h>
const long Nmax=1000002;
long long phi[2*Nmax];
long n;
void totient()
{
for (long i = 1; i <= n; ++i)
phi[i] = i-1;
for (long i = 2; i <= n; ++i)
for (long j = 2*i; j <= n; j += i)
phi[j] -= phi[i];
}
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
long long s=0;
scanf("%d",&n);
totient();
for(int i=2;i<=n;i++)
s+=phi[i];
printf("%lld",2*s+1);
return 0;
}