/*CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC C C C GENERATE FAREY SERIES AND COMPUTE UPPER BOUND MINUS LOWER BOUND C C 05/29/14 (DKC) C C C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC*/ #include <stdio.h> #include <math.h> unsigned int euler(unsigned int a); unsigned int haros1(unsigned int N, unsigned int M, unsigned int *R, unsigned int H, unsigned int K, unsigned int HP, unsigned int KP); // unsigned int out=1; // 0 for sum, 1 for sqrt(sum) // void main() { unsigned int N,R[250000],MAXN; unsigned int L,I,temp; double sqsum,sum; FILE *Outfp; Outfp = fopen("out1b4.dat","w"); // // ORDER OF FAREY SERIES // MAXN=200; for (N=2; N<=MAXN; N++) { // // GENERATE FAREY SERIES // L=haros1(N,0,R,0,1,1,N); for (I=0; I<L; I++) { if (I!=0) { temp=euler(R[I]&0xffff); if ((temp/4)*4!=temp) sum=sum+1.0/(double)temp; } else sum=0.0; } printf("N=%d, sum=%e \n",N,sum); sqsum=sqrt(sum); if (out==0) fprintf(Outfp," %e\n",sum); else fprintf(Outfp," %e\n",sqsum); } fclose(Outfp); return; }