Pagini recente » Cod sursa (job #1888882) | Cod sursa (job #993913) | Cod sursa (job #2191343) | Cod sursa (job #2470678) | Cod sursa (job #83724)
Cod sursa(job #83724)
#include<fstream>
using namespace std;
long n;
long calc();
int CMMDC(int A,int B)
{
if(A>B)
{
int aux=A;
A=B;
B=aux;
}
if(B%A==0) return A;
int X=A/2;
while(X>=2)
{
if((A%X==0)&&(B%X==0))
return X;
X--;
}
return 1;
}
int main()
{
fstream f,g;
f.open("fractii.in",ios::in);
f>>n;
f.close();
g.open("fractii.out",ios::out);
g<<calc();
g.close();
return 0;
}
long calc()
{
long sum=0,i,j;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(CMMDC(i,j)==1 || (i==1||j==1))
sum++;
return sum;
}