Pagini recente » Cod sursa (job #1395269) | Cod sursa (job #1527734) | Cod sursa (job #1803763) | Cod sursa (job #1618418) | Cod sursa (job #875882)
Cod sursa(job #875882)
#include<stdio.h>
long o,n;
long cmmdc(long x, long y)
{ while(x!=y)
if(x>y)
x=x-y;
else
y=y-x;
return x;
}
int main()
{
FILE *f;
f=fopen("fractii.in","rt");
fscanf(f, "%d", &n);
fclose(f);
for(int i=2;i<=n;i++)
for(int j=i+1;j<=n;j++)
if(cmmdc(i,j)==1)
o++;
f=fopen("fractii.out","wt");
fprintf(f,"%d", o+o+n+n-1);
fclose(f);
return 0;
}