#include<cstring>
#include<iostream>
#include<ctime>
using namespace std;
#define N 100000005
bool vis[N];
int p[N], cnt, phi[N];
int Euler(int n){
int i, j, k;
phi[1] = 1;
for (i = 2; i < n; ++i){
if (!vis[i]){
p[cnt++] = i;
phi[i] = i - 1;
}
for (j = 0; j < cnt && i * p[j] < n; ++j){
vis[i * p[j]] = true;
if (i % p[j]) phi[i * p[j]] = phi[i] * phi[p[j]];
else {
phi[i * p[j]] = phi[i] * p[j];
break;
}
}
}
return cnt;
}
相关证明:http://blog.csdn.net/lytning/article/details/24432651?utm_source=tuicool
http://wenku.baidu.com/view/542961fdba0d4a7302763ad5.html