Pagini recente » Cod sursa (job #1418051) | Cod sursa (job #1050268) | Cod sursa (job #554245) | Cod sursa (job #1621749) | Cod sursa (job #2742570)
#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 - 1;
}
for(int i = 2; i <= N; i++) {
if(phi[i] == i) {
phi[i]--;
for(int j = i + i; 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;
}