Pagini recente » Cod sursa (job #2154419) | Cod sursa (job #2714816) | Cod sursa (job #2161035) | Cod sursa (job #2727354) | Cod sursa (job #514502)
Cod sursa(job #514502)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXN 1000001
int n;
long long ciur[MAXN];
void init_ciur(int val) {
for (int i = 0; i <= n; i++) {
ciur[i] = val;
}
}
void make_fi_of_n_ciur() {
for (int i = 2; i <= n; i++) {
if (ciur[i] & 1) {
ciur[i] = i - 1;
for (int pos = i << 1; pos <= n; pos += i) {
long long aux = pos / i;
ciur[pos] *= (i - 1);
while (aux % i == 0) {
ciur[pos] *= i;
aux /= i;
}
}
}
}
}
int main() {
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
scanf("%d", &n);
init_ciur(1);
make_fi_of_n_ciur();
long long sum = 1;
for (int i = 2; i <= n; i++) {
sum += 2*ciur[i];
}
printf("%lld\n", sum);
return 0;
}