UVA 10820 Send a Table
#include<bits/stdc++.h>
#define MAX_N 50005
using namespace std;
//求欧拉函数值 O(n^0.5)
int euler[MAX_N];
int sum[MAX_N];
//o(MAX_N)时间筛出欧拉函数值的表
void euler_phi2()
{
for(int i=0;i<MAX_N;i++)euler[i]=i;
for(int i=2;i<MAX_N;i++){
if(euler[i]==i){
for(int j=i;j<MAX_N;j+=i)euler[j]=euler[j]/i*(i-1);
}
}
}
void init()
{
euler_phi2();
for(int i=2;i<=50000;i++)
sum[i]=sum[i-1]+euler[i];
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif // ONLINE_JUDGE
int n;
init();
while(cin>>n)
{
if(!n)break;
if(n==1){cout<<1<<endl;continue;}
else{
int ans=2*sum[n]+1;
cout<<ans<<endl;
}
}
}