Pagini recente » Cod sursa (job #953203) | Cod sursa (job #2749725) | Cod sursa (job #2475877) | Cod sursa (job #157677) | Cod sursa (job #1025807)
#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-2);
for (i = 2; i <= n; i++)
for (unsigned j = 2 * i; j <= n; phi[j] -= phi[i], j += i);
for (i = 2; i <= n; x += phi[i++] * 2);
std::ofstream g("fractii.out");
g << x + 1;
g.close();
}