Pagini recente » Cod sursa (job #2450855) | Cod sursa (job #2076775) | Cod sursa (job #253539) | Cod sursa (job #2261752) | Cod sursa (job #2456548)
#include <iostream>
#include <fstream>
using namespace std;
int cmmdc(int x, int y)
{
if(x>y) return cmmdc(x-y, y);
else if(x<y) return cmmdc(x, y-x);
else return x;
}
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;
}