Pagini recente » Cod sursa (job #3354730) | Cod sursa (job #2178808) | Cod sursa (job #1865062) | Cod sursa (job #727233) | Cod sursa (job #3354739)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(v) begin(v), end(v)
#define al(v, l, r) begin(v) + l, begin(v) + r + 1
#define sz(v) static_cast<int>(v.size())
#define pb push_back
#define pob pop_back
#define fs first
#define sd second
constexpr int inf = 2e9;
constexpr ll infll = 4e18;
constexpr int N = 1e6 + 5;
int n, phi[N];
signed main() {
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
cin >> n;
iota(al(phi, 1, n), 1);
for (int i = 2; i <= n; ++i) {
if (phi[i] != i) {
continue;
}
for (int j = i; j <= n; j += i) {
phi[j] -= phi[j] / i;
}
}
ll ans = -1; ///ca sa nu numaram 1/1 de 2 ori
for (int i = 1; i <= n; ++i) {
ans += phi[i] << 1;
}
cout << ans << "\n";
}