Pagini recente » Cod sursa (job #1989975) | Cod sursa (job #1115903) | Cod sursa (job #1896727) | Cod sursa (job #1233499) | Cod sursa (job #1265292)
#include <cstdio>
using namespace std;
int N,phi[1000005];
long long ans;
long long lg_put(long long a,long long b)
{
long long x1 = a,x2 = 1;
if( b == 0 ) return 1;
if( b == 1 ) return a;
while(b > 1){
if(b & 1){
x2 = x1 * x2;
b ^= 1;
}
else
{
x1 = x1 * x1;
b >>= 1;
}
}
return x1 * x2;
}
long long fi(int x){
int d = 2,p = 0,rez = 1;
while(x > 1){
if(x % d == 0)
{
while(x % d == 0){
++p;
x/=d;
}
rez *= (d - 1) * lg_put(d,p - 1);
}
++d;
p = 0;
}
return rez;
}
void solve()
{
for(int i = 2; i <= N; ++i)
phi[i] = fi(i);
for(int i = 2; i <= N; ++i)
ans += 2*phi[i];
ans ++;
}
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
scanf("%d",&N);
solve();
printf("%lld\n",ans);
return 0;
}