素数 "列挙" アルゴリズムを極めるスレ
■ このスレッドは過去ログ倉庫に格納されています
0425396
NGNG{
const MAX3=0x55555555;
unsigned char * tbl = malloc(0x20010000/3);
unsigned int n=5,m=1,n1,n2, d;
memset(tbl,0,0x20010000/3);
n1=3,n2=10,d=8;
while (n<0x10000){
if(!TestBits(tbl, m) ){
unsigned x = d;
printf("%5d\n",n);
while( x<MAX3){SetBit(tbl, x);SetBit(tbl, x+n1); x += n2;}
}n1+=2*m+4 /*(n*2+8)/3*/,n2+=4,d+=4*m+4 /*(n*4+4)/3*/,n+=2,m++;
if(!TestBits(tbl, m) ){
unsigned x = d;
printf("%5d\n",n);
while( x<MAX3){SetBit(tbl,x);SetBit(tbl,x+n1);x+=n2;}
}n1-=2*m-2 /*(n*2-8)/3*/,n2+=8,d+=8*m+8 /*(8*n+16)/3*/,n+=4,m++;
}
return tbl;
}
■ このスレッドは過去ログ倉庫に格納されています