Pagini recente » Cod sursa (job #1291404) | Cod sursa (job #1969420) | Borderou de evaluare (job #24871) | Cod sursa (job #2669977) | Cod sursa (job #1959325)
#include <iostream>
#include <fstream>
using namespace std;
int n,cmmdc,a,b,i,j,nr;
int main()
{
ifstream fin("fractii.in");
ofstream fout("fractii.out");
fin>>n;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
cmmdc=0;
a=i;
b=j;
if(a!=1 && b!=1)
{
while(a!=b)
{
if(a>b) a=a-b;
else b=b-a;
cmmdc=a;
}
if(cmmdc==1) nr++;
}
else
{
nr++;
}
}
}
fout<<nr;
return 0;
}