Pagini recente » Cod sursa (job #506501) | Cod sursa (job #2960171) | Cod sursa (job #2636564) | Cod sursa (job #2869800) | Cod sursa (job #2627612)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("fractii.in");
ofstream g("fractii.out");
long long n;
long long cmmdc (long long a, long long b) {
while (a != b) {
if (a > b) {
a = a - b;
} else {
b = b - a;
}
}
long long r = a;
return r;
}
int main () {
int nr = 1;
cin >> n;
for (int i = 1; i < n; i++) {
for (int j = i + 1; j <= n; j++) {
if (cmmdc(i, j) == 1) {
nr = nr + 2;
}
}
}
g << nr;
}