Pagini recente » Cod sursa (job #82154) | Cod sursa (job #971445) | Cod sursa (job #649665) | Cod sursa (job #843610) | Cod sursa (job #2780125)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
const int DIM = 1e6;
int N;
long long phi[DIM + 4], rez;
void getphi(int N) {
for(int i = 1; i <= N; i++) {
phi[i] = i;
}
for(int i = 2; i <= N; i++) {
if(phi[i] == i) {
phi[i]--;
for(int j = 2; j * i <= N; j++) {
phi[j * i] = phi[j * i] * (i - 1) / i;
} }
rez += phi[i];
}
}
int main() {
fin >> N;
getphi(N);
fout << 2 * rez + 1;
return 0;
}