/*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
C                                                                             C
C  COMPUTE SUM OF M(X/I) AND DETERMINE SIGN CHANGES OF M(X/I)		      C
C  06/02/14 (DKC)							      C
C                                                                             C
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC*/
#include <stdio.h>
#include <math.h>
unsigned int euler(unsigned int a);
double mertens1(unsigned int);
void main() {
unsigned int N,MAXN;
unsigned int i,index;
double sum,msum,max,temp,msave;
FILE *Outfp;
Outfp = fopen("out1b7.dat","w");
MAXN=1280;
for (N=2; N<=MAXN; N++) {
   sum=0.0;
   max=0.0;	    // maximum
   index=0;	    // index of maximum
   for (i=1; i<=N; i++) {
      msum=mertens1(N/i);
      if (i==1)
	msave=msum;
      if ((i>1)&&(i<=(N/2))) {
	 if (msum>0.0) {
	    printf("positive value: N=%d, index=%d, msum=%e, msave=%e \n",N,i,msum,msave);
	    fprintf(Outfp,"positive value: N=%d, index=%d, msum=%e, msave=%e \n",N,i,msum,msave);
//	    break;
	    }
	 }
      sum=sum+msum;
      temp=msum;	    // find maximum
      if (temp<0.0)
	 temp=-temp;
      if (temp>max) {
	 max=temp;
	 index=i;
	 }
      temp=euler(i);
      if ((temp/4)*4!=temp)
	 sum=sum+msum*(double)i/(double)temp;
//    printf(" %d %d %e %e \n",i,N/i,msum,sum);
//    fprintf(Outfp," %d %d %e %e \n",i,N/i,msum,sum);
      }
// printf("N=%d, index=%d, max=%e, sum=%e \n",N,index,max,sum);
// fprintf(Outfp,"N=%d, index=%d, max=%e, sum=%e \n",N,index,max,sum);
// fprintf(Outfp," %e\n",sum);
   }
fclose(Outfp);
return;
}