Pagini recente » Cod sursa (job #1882713) | Cod sursa (job #2340388) | Cod sursa (job #2894401) | Cod sursa (job #1366917) | Cod sursa (job #2128488)
#include <fstream>
#define p 1000005
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
int n, a[p];
long long function(int n)
{
long long s = 1;
for (int i = 2; i <= n; i++)
a[i] = i - 1;
for (int i = 2; i <= n; i++)
{
s += 2 * a[i];
for (int j =2 * i; j <= n; j += i)
a[j] -= a[i];
}
return s;
}
int main()
{
f >> n;
g << function(n);
}