Pagini recente » Cod sursa (job #2617309) | Cod sursa (job #3204955) | Cod sursa (job #908448) | Cod sursa (job #2756637) | Cod sursa (job #382830)
Cod sursa(job #382830)
#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) == 1)
total++;
N2++;
}
}
printf("%d\n", total);
return 0;
}
int aux1,aux2;
int Prime(int a, int b)
{
aux1 = a; aux2 = b;
if (aux1 == 1 || aux2 == 1)
return 1;
while (aux1 != 0 && aux2 != 0)
{
if (aux1 > aux2)
aux1 -= aux2;
else
aux2 -= aux1;
}
if ((aux1 > 1 && aux2 == 0) || (aux1 == 0 && aux2 > 1))
return 0;
else
return 1;
}