/*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C C COMPUTE DIFFERENCES IN NUMBER OF FRACTIONS C C 01/02/15 (DKC) C C C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC*/ #include <stdio.h> #include <math.h> int liouvile(unsigned int a); double numdiv(unsigned int a, unsigned int flag); mertens8(unsigned int, unsigned int *count); // unsigned int MAXN=10250; // 10250 unsigned int out=24; // 11, sum of m(x/i) // 12, sum of n(x/i) // 13, sum of n(x/i)-m(x/i) // 14, sum of (n(x/i)-m(x/i))*i // 17, differences in number of fractions before, after 1/4 // 18, number of fractions before 1/4 // 19, number of fractions after 1/4 // 24, sum of (n(x/i)-m(x/i))*d(i) // 25, sum of n(x/i)-m(x/i) when i is a perfect square // 26, sum of (n(x/i)-m(x/i))^2 // 27, sum of (n(x/i)-m(x/i))*log(i) // 28, sum of sgn(n(x/i)-m(x/i)) // 29, sum of (n(x/i)-m(x/i)*log(i)*d(i) // 30, sum of (n(x/i)-m(x/i)^2*L(i)^2 // 31, sum of sgn(n(x/i)-m(x/i))*i // 32, sum of |sgn(n(x/i)-m(x/i))| // void main() { int t,tsum; unsigned int N,i,temp,count[2]; double sum6,sum7,sum8,sum9,sum10,sum11,sum12,sum13,sum14,sum15,sum16,sum17,sum18; FILE *Outfp; Outfp = fopen("out1bd.dat","w"); for (N=2; N<=MAXN; N++) { printf(" %d \n",N); if ((out==17)||(out==18)||(out==19)) mertens8(N, count); if (out==17) { fprintf(Outfp," %d\n",(int)count[0]-(int)count[1]); continue; } if (out==18) { fprintf(Outfp," %d\n",count[0]); continue; } if (out==19) { fprintf(Outfp," %d\n",count[1]); continue; } if ((out==11)||(out==12)) { sum6=0.0; sum7=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); sum6=sum6+(double)count[0]; sum7=sum7+(double)count[1]; } if (out==11) fprintf(Outfp," %e\n",sum6); if (out==12) fprintf(Outfp," %e\n",sum7); continue; } if ((out==13)||(out==14)) { sum8=0.0; sum9=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); sum8=sum8+(double)count[1]-(double)count[0]; // h(x) sum9=sum9+(double)i*((double)count[1]-(double)count[0]); } if (out==13) fprintf(Outfp," %e\n",sum8); if (out==14) fprintf(Outfp," %e\n",sum9); continue; } if (out==24) { sum14=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); sum14=sum14+((double)count[1]-(double)count[0])*numdiv(i,1); } fprintf(Outfp," %e\n",sum14); continue; } if (out==25) { sum13=0.0; for (i=1; i<=N; i++) { temp=(unsigned int)(sqrt((double)i)+0.001); if ((temp*temp)==i) { mertens8(N/i, count); sum13=sum13+(double)count[1]-(double)count[0]; } } fprintf(Outfp," %e\n",sum13); continue; } if (out==26) { sum10=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); sum10=sum10+((double)count[1]-(double)count[0])*((double)count[1]-(double)count[0]); } fprintf(Outfp," %e\n",sum10); continue; } if (out==27) { sum11=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); sum11=sum11+((double)count[1]-(double)count[0])*log((double)i); } fprintf(Outfp," %e\n",sum11); continue; } if (out==28) { sum12=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); if (count[0]>count[1]) // sum of sgn(n(x/i)-m(x/i)) sum12=sum12-1.0; if (count[0]<count[1]) sum12=sum12+1.0; } fprintf(Outfp," %e\n",sum12); continue; } if (out==29) { sum18=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); sum18=sum18+((double)count[1]-(double)count[0])*log((double)i)*numdiv(i,1); } fprintf(Outfp," %e\n",sum18); continue; } if (out==30) { sum17=0.0; tsum=0; for (i=1; i<=N; i++) { mertens8(N/i, count); t=liouvile(i); tsum=tsum+t; sum17=sum17+((double)count[1]-(double)count[0])*((double)count[1]-(double)count[0])*(double)tsum*(double)tsum; } fprintf(Outfp," %e\n",sum17); continue; } if (out==31) { sum15=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); if (count[0]>count[1]) // sum of sgn(n(x/i)-m(x/i))*i sum15=sum15-(double)i; if (count[0]<count[1]) sum15=sum15+(double)i; } fprintf(Outfp," %e\n",sum15); continue; } if (out==32) { sum16=0.0; for (i=1; i<=N; i++) { mertens8(N/i, count); if (count[0]!=count[1]) // sum of |sgn(n(x/i)-m(x/i))| sum16=sum16+1.0; } fprintf(Outfp," %e\n",sum16); } } fclose(Outfp); return; }