Pagini recente » Cod sursa (job #2942254) | Cod sursa (job #1473316) | Cod sursa (job #134481) | Cod sursa (job #505370) | Cod sursa (job #2026847)
#include <stdio.h>
#include <stdlib.h>
long cmmdc(long a, long b) {
long t;
while (b != 0) {
t = b;
b = a % b;
a = t;
}
return a;
}
int main()
{
FILE *in = fopen("fractii.in", "r");
FILE *out = fopen("fractii.out", "w");
long n, p, q, nr;
fscanf(in, "%ld", &n);
nr = 0;
for(p = 1; p <= n; p++) {
for(q = 1; q <= n; q++) {
if(cmmdc(p,q) == 1) {
nr++;
}
}
}
fprintf(out, "%ld", nr);
return 0;
}