/*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C C COMPUTE MERTENS FUNCTION (using Deleglise and Rivat's algorithm) C C 08/31/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); double sumlo(unsigned int x, unsigned int u, int *mob, int *M); double sumhi(unsigned int x, unsigned int u, int *mob, int *M); unsigned int x=1000000; void main() { unsigned int i; int t; double f1,f2,f3; int *mobb; int *M; unsigned int u; FILE *Outfp; Outfp = fopen("out19.dat","w"); mobb=(int*) malloc(40000004); if (mobb==NULL) return; M=(int*) malloc(40000004); if (M==NULL) return; f1=log(log((double)x)); f1=f1*f1; f1=exp(1.0/3.0*log(f1)); f2=exp(1.0/3.0*log((double)x)); u=(unsigned int)(f1*f2); if ((x/u)>10000000) { printf("not enough memory \n"); goto zskip; } t=newmob(1,x/u,mobb,table); if (t!=1) { printf("too big \n"); goto zskip; } M[0]=1; for (i=1; i<=(x/u); i++) M[i]=M[i-1]+mobb[i]; f1=sumlo(x,u,mobb,M); f2=sumhi(x,u,mobb,M); f3=(double)M[u-1]-f1-f2; printf(" %d %d \n",x,(int)f3); zskip: fclose(Outfp); return; }