Pagini recente » Cod sursa (job #2518898) | Cod sursa (job #2197550) | Cod sursa (job #1979224) | Cod sursa (job #214570) | 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;
}