Cod sursa(job #2405191)

Utilizator gabi08Dron Ionut-Gabriel gabi08 Data 14 aprilie 2019 08:52:36
Problema Fractii Scor 10
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.45 kb
#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)
{
	if (y == 0)
		return (x == 1);
	else
		return f(y, x%y);
}