Pagini recente » Borderou de evaluare (job #1984108) | Cod sursa (job #963109) | Cod sursa (job #2250759) | Cod sursa (job #1508771) | Cod sursa (job #1025792)
#include <fstream>
int main()
{
unsigned i, n, phi[999999];
unsigned long x = 0;
std::ifstream f("fractii.in");
f >> n;
f.close();
for (i = 2; i <= n;i++)phi[i]=i-1;
for (i = 2; i <= n; i++)
for (unsigned j = 2 * i; j <= n; j += i)phi[j] -= phi[i];
for (i = 2; i <= n; i++) x += phi[i] * 2;
std::ofstream g("fractii.out");
g << x + 1;
g.close();
}