1 2 /* 交表 _________________________________________________________________________________ 3 4 #include <iostream> 5 #include <map> 6 #include <cmath> 7 #include <vector> 8 #include <cstdio> 9 #include <string> 10 #include <cstring> 11 #include <algorithm> 12 using namespace std; 13 #define fir first 14 #define sec second 15 #define pb(x) push_back(x) 16 #define mem(A, X) memset(A, X, sizeof A) 17 #define REP(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) 18 #define rep(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i)) 19 #define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e) 20 typedef long long LL; 21 typedef unsigned long long ull; 22 typedef pair<long,long> pll; 23 24 25 LL T,n; 26 const int mod=1e9+7; 27 const int maxn=1e5+10; 28 29 const int size=50000;//1-10000的表 30 int phi[size+1]; 31 void phi_table() // 1 到 n 的欧拉phi函数值表 ( O( nlg(lgn) ) ) 32 { 33 for(int i=2;i<=size;i++) 34 { 35 phi[i]=0; 36 } 37 phi[1]=1; 38 for(int i=2;i<=size;i++) 39 { 40 if(!phi[i]) 41 { 42 for(int j=i;j<=size;j+=i) 43 { 44 if(!phi[j]) phi[j]=j; 45 phi[j] = phi[j]/i*(i-1); 46 } 47 } 48 } 49 } 50 51 int main() 52 { 53 freopen("in.txt","r",stdin); 54 phi_table(); 55 while(cin>>n&&n) 56 //while(cin>>T) 57 { 58 //REP(kase,1,T) { } 59 LL ans=1; 60 REP(i,2,n) 61 ans+=2*phi[i]; 62 cout<<ans<<endl; 63 64 } 65 return 0; 66 } 67 68 /* 69 note : 70 debug : 71 optimize: 72 */