Cod sursa(job #875819)

Utilizator sandruSandru Petru-Ionut sandru Data 10 februarie 2013 20:27:40
Problema Fractii Scor 10
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.4 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(i%j==0);
				else
			if(cmmdc(i,j)==1)
				o++;
	f=fopen("fractii.out","wt");
	fprintf(f,"%d", o+n);
	fclose(f);
	return 0;
}