Pagini recente » Cod sursa (job #1450347) | Cod sursa (job #394198) | Cod sursa (job #394228) | Cod sursa (job #3139125) | Cod sursa (job #1493495)
#include <stdio.h>
long lnko(long a, long b)
{
while (a%b != 0)
{
if (a > b)
a = a%b;
else b = b%a;
}
return (a < b) ? a : b;
}
int main()
{
FILE *input = fopen("fractii.in", "r");
FILE *output = fopen("fractii.out", "w");
long n;
long counter;
fscanf(input, "%ld", &n);
counter = 0;
for (long i = 1; i <= n; i++)
{
for (long j = 1; j <= n; j++)
{
if (lnko(i, j) == 1)
counter++;
}
}
fprintf(output, "%ld", counter);
return 0;
}