Pagini recente » Cod sursa (job #2927733) | Cod sursa (job #801501) | Cod sursa (job #869299) | Cod sursa (job #1322387) | Cod sursa (job #382681)
Cod sursa(job #382681)
#include<stdio.h>
int main()
{
int N,N1 = 1, N2 = 1, total = 0;
freopen("fractii.in", "r", stdin);
freopen("fractii.out", "w", stdout);
scanf("%d", &N);
if (N >= 1)
{
while (N1 <= N)
{
if (N2 > N)
{
N1++; N2 = 1;
if (N1 > N)
break;
}
if (Prime(N1, N2) == 0)
total++;
N2++;
}
}
printf("%d\n", total);
return 0;
}
int Prime(int a, int b)
{
int max = a > b ? a : b;
int x;
for (x = 2; x <= max; x++)
if (a % x == 0 && b % x == 0)
return 1;
return 0;
}