#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=50000+5;
int phi[maxn];
void phi_table(int n,int* phi)
{
memset(phi,0,sizeof(phi));
phi[1]=1;
for(int i=2; i<=n; i++)
if(!phi[i])
for(int j=i; j<=n; j+=i)
{
if(!phi[j]) phi[j]=j;
phi[j] = phi[j] / i * (i-1);
}
} //紫书上1~n欧拉函数值用类似筛素数法优化后的函数
int main()
{
int m;
phi_table(maxn,phi);
for (int i = 3; i < maxn; i++)
phi[i]+=phi[i-1];
while(cin>>m&&m)
{
if(m==1) printf("1\n");
else
printf("%d\n", phi[m] * 2 + 1);
}
return 0;
}
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=50000+5;
int phi[maxn];
void phi_table(int n,int* phi)
{
memset(phi,0,sizeof(phi));
phi[1]=1;
for(int i=2; i<=n; i++)
if(!phi[i])
for(int j=i; j<=n; j+=i)
{
if(!phi[j]) phi[j]=j;
phi[j] = phi[j] / i * (i-1);
}
} //紫书上1~n欧拉函数值用类似筛素数法优化后的函数
int main()
{
int m;
phi_table(maxn,phi);
for (int i = 3; i < maxn; i++)
phi[i]+=phi[i-1];
while(cin>>m&&m)
{
if(m==1) printf("1\n");
else
printf("%d\n", phi[m] * 2 + 1);
}
return 0;
}