Pagini recente » Cod sursa (job #973447) | Cod sursa (job #1492562) | Cod sursa (job #881092) | Cod sursa (job #2742422) | Cod sursa (job #1628146)
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(int a,int b)
{
if(a==0 || b==0)
return a+b;
if(a>b)
return cmmdc(a%b,b);
else
return cmmdc(a,b%a);
}
int main()
{
int n,x,y,ok,s=0;
ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n;
if(n>1)
{
for(x=1;x<=n;x++)
{
for(y=1;y<=n;y++)
{
if(x!=y)
{
ok=cmmdc(x,y);
if(ok==1)
s++;
}
}
}
g<<s+1;
}
else
g<<0;
return 0;
}