Pagini recente » Cod sursa (job #746312) | Cod sursa (job #1490362) | Cod sursa (job #3193520) | Cod sursa (job #174653) | Cod sursa (job #3230942)
#include <bits/stdc++.h>
using namespace std;
const char nl = '\n';
const char sp = ' ';
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const char out[2][4]{ "NO", "YES" };
#define all(a) a.begin(), a.end()
using ll = long long;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
const int nmax = 1e6;
int n;
int phi[nmax + 5]{ 0 };
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
fin >> n;
for (int i = 1; i <= n; ++i) {
phi[i] = i;
}
for (int i = 2; i <= n; ++i) {
if (phi[i] == i) {
for (int j = i; j <= n; j += i) {
phi[j] = phi[j] / i * (i - 1);
}
}
}
fout << accumulate(phi + 1, phi + n + 1, 0ll) * 2 - 1;
}