Pagini recente » Cod sursa (job #2688643) | Cod sursa (job #1425751) | Cod sursa (job #2833141) | Cod sursa (job #1331517) | Cod sursa (job #1814896)
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
ifstream fi("fractii.in");
ofstream fo("fractii.out");
long long int phi[1000001];
long long int sol;
void indicator(long long int n)
{
for (int i = 1;i <= n;++i)
phi[i] = i - 1;
for (int i = 2;i <= n;++i)
{
for (int j = 2 * i;j <= n;j += i)
phi[j] -= phi[i];
sol += phi[i];
}
}
int main()
{
int n;
fi >> n;
indicator(n);
fo << 2 * sol + 1;
return 0;
}