Pagini recente » Cod sursa (job #985718) | Cod sursa (job #201804) | Cod sursa (job #1342956) | Cod sursa (job #949970) | Cod sursa (job #1561664)
#include<fstream>
using namespace std;
#define dim 1000002
int n;
long long sol=0;
int v[dim];
int main (){
ifstream fin("fractii.in");
ofstream fout("fractii.out");
fin>>n;
for(int i=1;i<=n;++i)
v[i]=i-1;
for(int i=2;i<=n;++i)
for(int j=2;j<=n;++j)
v[i*j]-=v[i];
for(int i=2;i<=n;++i)
sol=sol+v[i];
sol=2*sol+1;
fout<<sol;
fin.close();
fout.close();
/*
int cmmdc (int a, int b) {
while (a!=b)
{if (a>b) a=a-b; else b=b-a;
}
return b;
}
int main(){
int n, i, j, k=0;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
fin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{ if( cmmdc(i,j)==1) {k=k+1;}
}
fout<<k;
fin.close();
fout.close();*/
}