Pagini recente » Cod sursa (job #437230) | Cod sursa (job #1402965) | Cod sursa (job #2998491) | Cod sursa (job #623254) | Cod sursa (job #2381304)
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream f("fractii.in");
ofstream g("fractii.out");
int n;
f>>n;
int i,j,t=n*2-1,k;
bool c;
for (i=2;i<=n;i++)
{
for (j=2;j<=n;j++)
{
if (i!=j)
{
c=true;
k=2;
while (c&&k<=min(i,j))
{
if (i%k==0&&j%k==0) c=false;
else k++;
}
if (c) t++;
}
}
}
g<<t;
g.close();
f.close();
return 0;
}