Cod sursa(job #286803)
Utilizator | Data | 24 martie 2009 10:40:13 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<fstream.h>
int cmmdc(long a, long b)
{long c;
do
{c=a%b;
a=b;
b=c;
}while(c!=0);
return a;
}
main()
{long n,k,j,cont=0;
ifstream i("fractii.in");
ofstream o("fractii.out");
i>>n;cont=2*n-1;
for(k=2;k<=n;k++)
for(j=2;j<=n;j++)
if(cmmdc(k,j)==1)
cont++;
o<<cont<<'\n';
i.close();
o.close();
return 0;
}