Cod sursa(job #11738)
Utilizator | Data | 1 februarie 2007 15:20:42 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.35 kb |
#include<fstream.h>
int dc(unsigned long a,unsigned long b)
{unsigned long r;
while(r)
{r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{unsigned long n,s,i,j;
ifstream f("fractii.in");
f>>n;
f.close();
s=0;
for(i=1;i<=n;i++)
{for(j=1;j<=n;j++)
if(dc(i,j)==1)s++;
}
ofstream g("fractii.out");
g<<s<<'\n';
g.close();
return 0;
}