Pagini recente » Cod sursa (job #848307) | Cod sursa (job #1788965) | Cod sursa (job #2410480) | Cod sursa (job #263369) | Cod sursa (job #2271064)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int n;
ll ans, cnt[1000100], phi[1000100];
int main() {
in >> n;
for (int i = 1; i <= n; i++)
phi[i] = i;
for (int i = 2; i <= n; i++) {
if (cnt[i])
continue;
phi[i]--;
cnt[i]++;
for (int j = i + i; j <= n; j += i) {
phi[j] -= j / i;
cnt[j]++;
}
}
for (int i = 1; i <= n; i++)
ans += phi[i] + cnt[i] - 1;
ans++;
out << 2LL * ans - 1LL;
return 0;
}