Pagini recente » Cod sursa (job #1004512) | Istoria paginii runda/simulare_oni_2016_1/clasament | Cod sursa (job #2204643) | Cod sursa (job #1092489) | Cod sursa (job #1025846)
#include <fstream>
int main()
{
unsigned i, n, phi[999999];
unsigned long long x = 0;
std::ifstream f("fractii.in");
f >> n;
f.close();
for (i = 2; i <= n;phi[i]=i, i++);
for (i = 2; i <= n; i++)
if (phi[i] == i)
for (unsigned j = i; j <= n; phi[j] /= i,phi[j]*=i - 1,j+=i);
for (i = 2; i <= n; x+=phi[i++]*2);
std::ofstream g("fractii.out");
g << x + 1;
g.close();
}