Pagini recente » Cod sursa (job #1290841) | Cod sursa (job #1387776) | Cod sursa (job #628958) | Cod sursa (job #2025245) | Cod sursa (job #2029993)
#include <iostream>
#include <fstream>
using namespace std;
int euclid(int a,int b)
{
int r;
if (b<a)
{
r=a;
a=b;
b=r;
}
while (b>0)
{
r=a%b;
a=b;
b=r;
}
return a;
}
int main()
{
int n;
ifstream in("fractii.in");
ofstream out("fractii.out");
in>>n;
int i,j;
int s=0;
int aux=0;
for (i=1;i<=n;i++)
{
for (j=1;j<=n;j++)
if (euclid(i,j)==1)
{
s++;
aux++;
// out<<i<<"/"<<j<<" ";
}
//out<<" f="<<aux<<"\n";
aux=0;
}
//out<<"\n"<<"s="<<s;
out<<s;
out.close();
in.close();
return 0;
}