Pagini recente » Cod sursa (job #1389715) | Cod sursa (job #972635) | Cod sursa (job #1013931) | Cod sursa (job #132099) | Cod sursa (job #828690)
Cod sursa(job #828690)
#include<iostream>
#include<fstream>
using namespace std;
long i,j, n, nr;
int cmmdc(int x,int y);
int main()
{
ifstream in("fractii.in");
ofstream out("fractii.out");
in>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(cmmdc(i,j)==1)
nr++;
out<<nr;
out.close();
return 0;
}
/*{
int a=(i%j);
int b=(j%i);
if (a%b!=1 && b%a!=1)
{
suma++;
cout<<i<<" "<<j<<endl;
}
}*/
int cmmmdc(int x, int y)
{
if(x==0)
return y;
else
if(y==0)
return x;
else
return cmmdc(y,x%y);
}