Cod sursa(job #1458781)
Utilizator | Data | 8 iulie 2015 14:03:44 | |
---|---|---|---|
Problema | Fractii | Scor | 10 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int cmmdc(int x, int y)
{ while(x!=y)
if(x>y)
x=x-y;
else y=y-x;
return x;
}
int main ()
{
int i,j;
long long n,nr=0;
fin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
if(cmmdc(i,j)==1)
nr++;
fout<<nr;
}