Pagini recente » Cod sursa (job #1552307) | Cod sursa (job #1073571) | Cod sursa (job #1461690) | Cod sursa (job #1946178) | Cod sursa (job #218838)
Cod sursa(job #218838)
#include <stdio.h>
int n,nr,i,j,k;
bool gasit;
int main()
{
freopen("fractii.in","r",stdin);
freopen("fractii.out","w",stdout);
scanf("%d",&n);
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
{
gasit = 0;
if ((i%2!=0) || (j%2!=0))
{
if (i > j)
{
if ((i%j == 0) && (j > 1))
gasit = 1;
else for (k = 3; k <= (i/2); k+=2)
if ((i%k == 0) && (j%k == 0))
{
gasit = 1;
break;
}
else {}
}
else
{
if ((j%i == 0) && (i > 1))
gasit = 1;
else for (k = 3; k <= (j/2); k+=2)
if ((i%k == 0) && (j%k == 0))
{
gasit = 1;
break;
}
else {}
}
}
else gasit = 1;
if (!gasit)
nr++;
}
printf("%d",nr);
return 0;
}