Do not use Eratosthene sieve if n < 1e6 since we have a static primes list
parent
2bbf9f3297
commit
aaa4b2a62f
|
@ -1,6 +1,7 @@
|
||||||
! Copyright (c) 2007 Samuel Tardieu.
|
! Copyright (c) 2007 Samuel Tardieu.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: bit-arrays kernel lazy-lists math math.functions math.ranges sequences ;
|
USING: bit-arrays kernel lazy-lists math math.functions math.primes.list
|
||||||
|
math.ranges sequences ;
|
||||||
IN: math.erato
|
IN: math.erato
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
@ -35,4 +36,8 @@ TUPLE: erato limit bits latest ;
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: lerato ( n -- lazy-list )
|
: lerato ( n -- lazy-list )
|
||||||
<erato> 2 [ drop next-prime ] curry* lfrom-by [ ] lwhile ;
|
dup 1000003 < [
|
||||||
|
0 primes-under-million seq>list swap [ <= ] curry lwhile
|
||||||
|
] [
|
||||||
|
<erato> 2 [ drop next-prime ] curry* lfrom-by [ ] lwhile
|
||||||
|
] if ;
|
||||||
|
|
Loading…
Reference in New Issue