Pagini recente » Cod sursa (job #960366) | Cod sursa (job #543322) | Cod sursa (job #3168147) | Cod sursa (job #2368206) | Cod sursa (job #2405189)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("fractii.in");
ofstream out("fractii.out");
int n, sol;
bool f(int, int);
int main()
{
in >> n;
for (int i = 1; i <= n; ++i)
{
for (int j = i; j <= n; ++j)
{
if (i != j)
sol += 2 * f(i, j);
else
sol += f(i, j);
}
}
out << sol;
system("pause");
}
bool f(int x, int y)
{
while (x != y)
{
(x > y) ? x -= y : y -= x;
}
return (x == 1);
}