/*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C C COMPUTE MERTENS FUNCTION (local maxima) C C 09/06/15 (DKC) C C C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC*/ #include <stdio.h> #include <math.h> #include "table2.h" extern char *malloc(); int newmob(unsigned int a, unsigned int b, int *out, unsigned int *table); unsigned int MAXN=400000000; // maximum N unsigned int BEGINN=2; // beginning N // void main() { int t,*M; unsigned int N,h,i,j,count; double sum,maxt; FILE *Outfp; Outfp = fopen("out1bze.dat","w"); // // compute Mertens function // M=(int*) malloc(1600000004); if (M==NULL) return; t=newmob(1,MAXN+1,M,table); if (t!=1) { printf("too big \n"); goto zskip; } for (i=1; i<MAXN; i++) M[i]=M[i-1]+M[i]; M[0]=1; // maxt=0.0; for (N=BEGINN; N<=MAXN; N++) { sum=0.0; count=0; h=(unsigned int)sqrt((double)(N+1)); for (i=1; i<=h; i++) { j=N/i; if (N==(j*i)) { t=M[j-1]; sum=sum+(double)t*(double)t; count=count+1; if (j!=i) { t=M[i-1]; sum=sum+(double)t*(double)t; count=count+1; } } } if (sum>maxt) { maxt=sum; printf(" %d %e %d \n",N,maxt,count); fprintf(Outfp," %d, %d, %d, \n",N,(unsigned int)maxt,count); } } zskip: fclose(Outfp); return; }