Pagini recente » Rating Patainea Robert (RobertPatainea) | Cod sursa (job #673913) | civilizatie | Cod sursa (job #494544) | Cod sursa (job #2476769)
#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=0;
fin>>x;
for (int i=1;i<=x;i++)
{
sum+=form_calc(i);
}
sum=sum*2-1;
fout<<sum;
return 0;
}