欧拉函数前缀合
#include<cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define fst first
#define sec second
#define sci(num) scanf("%d",&num)
#define scl(num) scanf("%lld",&num)
#define mem(a,b) memset(a,b,sizeof a)
#define cpy(a,b) memcopy(a,b,sizeof b)
typedef long long LL;
typedef pair<int,int> P;
const int MAX_M = 10000;
const int MAX_N = 1e6 +100;
LL phi[MAX_N];
void init() {
mem(phi,0);
for (int i = 2;i <MAX_N;i++) {
if (phi[i]) continue;
for (int j = i;j < MAX_N;j += i) {
if (!phi[j]) phi[j] = j;
phi[j] = phi[j] / i * (i - 1);
}
}
for (int i = 2;i < MAX_N;i++) {
phi[i] += phi[i - 1];
}
}
int main() {
init();
int N;
while (~scanf("%d",&N)) {
if (N == 0 ) break;
printf("%lld\n",phi[N]);
}
return 0;
}