Pagini recente » Cod sursa (job #2697983) | Cod sursa (job #1193442) | Cod sursa (job #2777615) | Cod sursa (job #2509520) | Cod sursa (job #2640504)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int eulerTotient[1000005];
int main()
{
int n;
unsigned long long count = 1;
fin >> n;
for (int i = 1; i <= n; ++i)
eulerTotient[i] = i;
for (int i = 2; i <= n; ++i)
if (eulerTotient[i] == i)
{
--eulerTotient[i];
for (int j = i + i; j <= n; j += i)
eulerTotient[j] = eulerTotient[j] / i * (i - 1);
}
for (int i = 2; i <= n; ++i)
count += eulerTotient[i] + eulerTotient[i];
fout << count;
return 0;
}