Cod sursa(job #875810)
Utilizator | Data | 10 februarie 2013 20:21:28 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.37 kb |
#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=1;i<=n;i++)
for(int j=1;j<=n;j++)
if(cmmdc(i,j)==1)
o++;
f=fopen("fractii.out","wt");
fprintf(f,"%d", o);
fclose(f);
return 0;
}