Pagini recente » Cod sursa (job #2553733) | Cod sursa (job #1178640) | Cod sursa (job #1888785) | Cod sursa (job #1853939) | Cod sursa (job #2456551)
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(int x, int y)
{
if (!y) return x;
return cmmdc(y, x % y);
}
int main()
{
ifstream f("fractii.in");
ofstream g("fractii.out");
int n, nr, x, y;
f >> n;
nr = n;
for(int x=2; x<=n; x++) {
nr++;
for(int y=2; y<=n; y++)
if(cmmdc(x, y) == 1)
nr++;
}
g << nr;
f.close();
g.close();
return 0;
}