|
|
nsieveroutine nsieve( bits : array<int>, m=0 ) { bits[] = 1; count = 0; for( i = 2 : m ){ if( bits[i] ){ count ++; for( k = i+i : i : m ) bits[k] = 0; } } return count; } routine main( n = 2 ) { m = 10000 * (1< bits = [ 0 : m + 1 ]; stdio.printf("Primes up to %8d %8d\n", m, nsieve(bits, m) ); m = 10000 * (1<<(n-1)); stdio.printf("Primes up to %8d %8d\n", m, nsieve(bits, m) ); m = 10000 * (1<<(n-2)); stdio.printf("Primes up to %8d %8d\n", m, nsieve(bits, m) ); }
view count 1175 times
created at 2009-02-20, 16:29 GMT |
fu: ... I forgot to say something about the plan for the whole new year in my previous reply. Well, besides w ... (Jan.19,01:40) fu: ... Happy new dragon year (which will start from this sunday)! Actually, it was a busy month (I wish th ... (Jan.18,22:46) ybabel: What's the plan for the new year ? Hello 'vry budy :- ) happy new year (when is the new year for you Fu ?) I saw you come back and comm ... (Jan.18,18:59) |