diff --git a/basis/math/primes/erato/erato.factor b/basis/math/primes/erato/erato.factor index 6148f5db68..66e7272d0f 100644 --- a/basis/math/primes/erato/erato.factor +++ b/basis/math/primes/erato/erato.factor @@ -7,6 +7,11 @@ IN: math.primes.erato step - i i fixnum*fast - [ dup upper <= ] [ - [ sieve unmark ] [ step fixnum+fast ] bi - ] while drop - ] when ; inline + i 2 fixnum*fast :> step + i i fixnum*fast + [ dup upper <= ] [ + [ sieve unmark ] [ step fixnum+fast ] bi + ] while drop ; inline : init-sieve ( n -- sieve ) 30 /i 1 + [ 255 ] B{ } replicate-as ; inline @@ -44,9 +47,11 @@ PRIVATE> :: sieve ( n -- sieve ) n integer>fixnum-strict init-sieve :> sieve sieve upper-bound >fixnum :> upper - 3 upper sqrt 2 - [ upper sieve unmark-multiples ] each - sieve ; + 3 upper sqrt 2 [| i | + i sieve marked-unsafe? [ + i upper sieve unmark-multiples + ] when + ] each sieve ; : marked-prime? ( n sieve -- ? ) [ integer>fixnum-strict ] dip