]> gitweb.factorcode.org Git - factor.git/commitdiff
math.primes.erato.fast: use literals to show how the wheel is calculated.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 17 Jun 2015 01:44:08 +0000 (18:44 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 17 Jun 2015 01:44:08 +0000 (18:44 -0700)
basis/math/primes/erato/fast/fast.factor

index 36ea07631d10275aab73bb097a7e10021d2d298b..d52981dba4f9426651db785c173804de34d485b7 100644 (file)
@@ -1,17 +1,19 @@
 ! Copyright (C) 2015 John Benediktsson
 ! See http://factorcode.org/license.txt for BSD license
 
-USING: bit-arrays fry kernel kernel.private locals math
-math.functions math.private sequences sequences.private ;
+USING: bit-arrays fry kernel kernel.private literals locals math
+math.functions math.private math.ranges math.statistics
+sequences sequences.private ;
 
 IN: math.primes.erato.fast
 
 <PRIVATE
 
-CONSTANT: wheel-2-3-5-7 B{
-    2 4 2 4 6 2 6 4 2 4 6 6 2 6 4 2 6 4 6 8 4 2 4 2 4 8 6 4 6 2
-    4 6 2 6 6 4 2 4 6 2 6 4 2 4 2 10 2 10
-}
+CONSTANT: wheel-2-3-5-7 $[
+    11 dup 210 + [a,b] [
+        { 2 3 5 7 } [ divisor? ] with any? not
+    ] B{ } filter-as differences
+]
 
 :: each-prime ( upto sieve quot -- )
     11 upto integer>fixnum-strict '[ dup _ <= ] [