Cod sursa(job #815366)
Utilizator | Data | 16 noiembrie 2012 21:36:28 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.4 kb |
#include<fstream.h>
unsigned long cmmdc(unsigned long a,unsigned long b)
{while(a!=b)
if(a>b)
a=a-b;
else
b=b-a;
return a;}
main()
{ifstream in("fractii.in.txt");
ofstream out("fractii.out.txt");
unsigned long N,i,j,p=0;
in>>N;
for(i=1;i<=N;i++)
for(j=1;j<=N;j++)
if(cmmdc(i,j)==1)
p=p+1;
out<<p;
in.close();
out.close();
}