Pagini recente » Cod sursa (job #450280) | Cod sursa (job #1196513) | Cod sursa (job #1348213) | Cod sursa (job #607985) | Cod sursa (job #204807)
Cod sursa(job #204807)
#include <stdio.h>
FILE *f,*g;
int p[100][100];
long i,j,n,contor;
int validare(long x,long y)
{
int i;
if(y % x == 0) return 0;
for(i=2;i<=x;i++)
if(p[x][i]!=0)
if(p[x][i]==p[y][i])
return 0;
return 1;
}
int main()
{
f=fopen("fractii.in","r");
g=fopen("fractii.out","w");
fscanf(f,"%ld\n",&n);
for(i=2;i<=n;i++)
for(j=2;j<=i;j++)
if(i % j == 0)
p[i][j]=1;
contor=2*n-1;
for(i=2;i<n;i++)
for(j=i+1;j<=n;j++)
contor+=2*validare(i,j);
fprintf(g,"%ld\n",contor);
fclose(f); fclose(g);
return 0;
}