Pagini recente » Cod sursa (job #263697) | Cod sursa (job #2742544) | Cod sursa (job #2326458) | Cod sursa (job #2859832) | 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;
}