Pagini recente » Cod sursa (job #558177) | Borderou de evaluare (job #2550147) | Cod sursa (job #661703) | Cod sursa (job #1677864) | Cod sursa (job #3274335)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("fractii.in");
ofstream fout ("fractii.out");
const int nmax=1e6;
int n, phi[nmax];
void eratostene ()
{
phi[0]=phi[1]=1;
for (int i=2; i<=nmax; i++)
phi[i]=i-1;
for (int i=2; i<=nmax; i++)
{
for (int j=2*i; j<=nmax; j+=i)
phi[j]-=phi[i];
}
}
int main()
{
fin >> n;
eratostene();
int rez=0;
for (int i=1; i<=n; i++)
rez+=phi[i];
fout << rez*2-1;
return 0;
}