Pagini recente » Cod sursa (job #2854074) | Cod sursa (job #2948730) | Cod sursa (job #531857) | Cod sursa (job #1952716) | Cod sursa (job #2823738)
#include <fstream>
using namespace std;
ifstream fin("fractii.in");
ofstream fout("fractii.out");
int CMMDC(int a, int b)
{
while(b != 0)
{
int r = a % b;
a = b;
b = r;
}
return a;
}
int main()
{
int n, fraction = 1;
fin >> n;
for(int i = 1; i <= n; ++i)
for(int j = i + 1; j <= n; ++j)
if(CMMDC(i, j) == 1)
fraction += 2;
fout << fraction;
return 0;
}