Cod sursa(job #255558)
Utilizator | Data | 9 februarie 2009 22:56:54 | |
---|---|---|---|
Problema | Fractii | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.38 kb |
#include<fstream.h>
#include<conio.h>
long int cmmmdc(long int a, long int b)
{while(a!=b){
if(a<b) b=b-a;
else a=a-b;
}
return b;
}
void main(){
long int n,i,j,a=1;
ifstream f("fractii.in");
ofstream g("fractii.out");
f>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(cmmmdc(i,j)==1 && i!=j) a++;
g<<"numarul de fractii "<<a;
}