Pagini recente » Cod sursa (job #71095) | Cod sursa (job #1692182) | Cod sursa (job #2944817) | Cod sursa (job #745440) | Cod sursa (job #2640495)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int eulerTotient[1000005];
int main()
{
int n;
int 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;
}