Pagini recente » Cod sursa (job #482512) | Cod sursa (job #520238) | Cod sursa (job #1448233) | Cod sursa (job #3127784) | Cod sursa (job #2204418)
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;
#define MAXN 1000001
int totient[MAXN];
int main() {
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
int n;
scanf("%d", &n);
for (int i = 1; i <= n; ++i) {
totient[i] = i - 1;
}
int sum = 0;
for (int i = 2; i <= n; ++i) {
for (int j = i + i; j <= n; j += i) {
totient[j] -= totient[i];
}
sum += totient[i];
}
printf("%d", sum * 2 + 1);
return 0;
}