Cod sursa(job #7959)
Utilizator | Data | 23 ianuarie 2007 14:55:02 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.33 kb |
#include<fstream.h>
long int i,j,nr,n;
int cmmdc(int x,int y)
{
if(x>y)
return cmmdc(x-y,y);
if(x<y)
return cmmdc(x,y-x);
return x;
}
int main()
{
ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(cmmdc(i,j)==1)
nr++;
g<<nr;
return 0;
}