Pagini recente » Cod sursa (job #1002345) | Cod sursa (job #1941546) | Cod sursa (job #1218215) | Cod sursa (job #1115139) | Cod sursa (job #1454220)
#include <bits/stdc++.h>
int phi[1000001];
int main() {
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
int n;
scanf("%d", &n);
for (int i = 2; 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] = (long long) phi[j] * (i - 1) / i;
long long res = 1;
for (int i = 2; i <= n; ++i)
res += 2 * phi[i];
printf("%lld", res);
return 0;
}