1 IN: benchmark.nsieve-bits
2 USING: math math.parser sequences sequences.private kernel
5 : clear-flags ( step i seq -- )
9 f 2over set-nth-unsafe [ over + ] dip clear-flags
10 ] if ; inline recursive
12 : (nsieve-bits) ( count i seq -- count )
15 over dup 2 * pick clear-flags
16 rot 1+ -rot ! increment count
17 ] when [ 1+ ] dip (nsieve-bits)
20 ] if ; inline recursive
22 : nsieve-bits ( m -- count )
23 0 2 rot 1+ <bit-array> dup set-bits (nsieve-bits) ;
25 : nsieve-bits. ( m -- )
26 [ "Primes up to " % dup # " " % nsieve-bits # ] "" make
29 : nsieve-bits-main ( n -- )
30 dup 2^ 10000 * nsieve-bits.
31 dup 1- 2^ 10000 * nsieve-bits.
32 2 - 2^ 10000 * nsieve-bits. ;
34 : nsieve-bits-main* ( -- ) 11 nsieve-bits-main ;
36 MAIN: nsieve-bits-main*