(euler060) ( -- primes )


Vocabulary
project-euler.060

Inputs
None

Outputs
primesan object


Definition


:: (euler060) ( -- primes )
[
1/0. :> result! 10000 primes-upto :> primes1 primes1
amb-integer :> i i primes1 nth :> a primes1 i 1 +
tail-slice
[ { [ 4 * a + result < ] [ a prime-pair? ] } 1&& ]
filter :> primes2 primes2 amb-integer :> j j primes2 nth
:> b primes2 j 1 + tail-slice
[ { [ 3 * a b + + result < ] [ b prime-pair? ] } 1&& ]
filter :> primes3 primes3 amb-integer :> k k primes3 nth
:> c primes3 k 1 + tail-slice [
{ [ 2 * a b c + + + result < ] [ c prime-pair? ] }
1&&
] filter
:> primes4 primes4 amb-integer :> l l primes4 nth
:> d primes4 l 1 + tail-slice [
{ [ a b c d + + + + result < ] [ d prime-pair? ] }
1&&
] filter :> primes5 primes5 amb-lazy :> e
{ a b c d e } dup sum result!
] bag-of last ;