Pagini recente » Cod sursa (job #1438352) | Cod sursa (job #1573419) | Cod sursa (job #1852548) | Cod sursa (job #897831) | Cod sursa (job #2476787)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("fractii.in");
ofstream fout ("fractii.out");
int form_calc (int x)
{
int aux=x;
long long p=x;
if (x%2==0)
{
p=(p/2);
while (x%2==0)
x=x/2;
}
for (int d=3; d*d<=aux; d+=2)
{
if (x%d==0)
{
p=(p/d)*(d-1);
while (x%d==0)
x=x/d;
}
d+=2;
}
if (x>1)
p=(p/x)*(x-1);
return p;
}
int main()
{
int x;
long long sum=1;
fin>>x;
for (int i=2;i<=x;i++)
{
sum+=2*form_calc(i);
}
fout<<sum;
return 0;
}