Pagini recente » Cod sursa (job #1896676) | Cod sursa (job #2896891) | Cod sursa (job #193367) | Cod sursa (job #2037817) | Cod sursa (job #96084)
Cod sursa(job #96084)
#include <fstream.h>
#include <math.h>
int cmmdc(long int a,long int b)
{
long int r;
int x=1;
int i;
if((a%b==0) || (b%a==0)) return 0;
while(x)
{
r=a%b;
a=b;
b=r;
if(r<2) x=0;
}
if(r>1)return 0;else return 1;
}
int main()
{
long int x,n,i,j;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
fin>>n;
fin.close();
x=0;
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
x+=2*cmmdc(i,j);
fout<<x;
fout.close();
return 0;
}