diff --git a/basis/math/primes/primes.factor b/basis/math/primes/primes.factor index 5dc6a51334..7e877a03ce 100644 --- a/basis/math/primes/primes.factor +++ b/basis/math/primes/primes.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2007-2009 Samuel Tardieu. ! See http://factorcode.org/license.txt for BSD license. -USING: combinators fry kernel math math.bitwise math.functions -math.order math.primes.erato math.primes.erato.private -math.primes.miller-rabin math.ranges literals random sequences sets -vectors ; +USING: combinators combinators.short-circuit fry kernel math +math.bitwise math.functions math.order math.primes.erato +math.primes.erato.private math.primes.miller-rabin math.ranges +literals random sequences sets vectors ; IN: math.primes ] keep 3 < [ [ 2 swap push ] keep ] when ; +: simple? ( n -- ? ) { [ even? ] [ 3 mod 0 = ] [ 5 mod 0 = ] } 1|| ; + PRIVATE> : prime? ( n -- ? ) { { [ dup 7 < ] [ { 2 3 5 } member? ] } - { [ dup even? ] [ 2 = ] } + { [ dup simple? ] [ drop f ] } [ (prime?) ] } cond ; foldable