Pagini recente » Cod sursa (job #2730459) | Cod sursa (job #1365689) | Cod sursa (job #1661677) | Cod sursa (job #1808921) | Cod sursa (job #92257)
Cod sursa(job #92257)
#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 = 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);
return 0;
}