Pagini recente » Cod sursa (job #3288298) | Cod sursa (job #1747681) | Cod sursa (job #2070196) | Cod sursa (job #1892638) | Cod sursa (job #17682)
Cod sursa(job #17682)
//16.02.2007
#include<stdio.h>
int ireductibil(long a, long b)
{
long d,m;
if(a>b) m=a;
else m=b;
for(d=2; d<=m/2; d++)
{if( (a%d==0) && (b%d==0) )
return 0;}
return 1;
}
int main()
{
long n,i,j,k=0;
FILE *f=fopen("fractii.in", "r");
FILE *g=fopen("fractii.out", "w");
fscanf(f, "%d", &n);
for(i=1; i<=n; i++)
{
for(j=1; j<n; j++)
{if(ireductibil(i,j)) k++;}
}
fprintf(g, "%d", k);
fclose(f);
fclose(g);
printf("\n");
return 0;
}