Pagini recente » Cod sursa (job #359834) | Cod sursa (job #2227041) | Cod sursa (job #2711925) | Cod sursa (job #69129) | Cod sursa (job #92267)
Cod sursa(job #92267)
#include <stdio.h>
#include <math.h>
long n;
long gcd(long a, long b) {
long c = 0;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
return a;
}
int main() {
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
scanf("%ld", &n);
long i, j;
long long sol = 0;
long a, b, c;
for (i = 1; i <= n; ++i) {
for (j = i+1; j <= n; ++j) {
a = i, b = j;
while (b != 0) {
c = a % b;
a = b;
b = c;
}
if (a == 1) ++sol;
}
}
printf("%lld\n", sol * 2 + 1);
return 0;
}