diff --git a/extra/project-euler/087/087.factor b/extra/project-euler/087/087.factor index c20498415c..0367e7a5a3 100644 --- a/extra/project-euler/087/087.factor +++ b/extra/project-euler/087/087.factor @@ -1,29 +1,53 @@ -USING: locals math math.primes sequences math.functions sets kernel ; +USING: locals math math.functions math.primes +project-euler.common sequences sets ; + IN: project-euler.087 -> O((n / log n)^(13/12)) ! -! When n = 50000000, the first equation is approximately 10 million and -! the second is approximately 2 billion. +! When n = 50,000,000, the first equation is approximately 10 +! million and the second is approximately 2 billion. :: prime-triples ( n -- answer ) n sqrt primes-upto :> primes @@ -32,9 +56,11 @@ IN: project-euler.087 primes 4 n prime-powers-less-than :> primes^4 primes^2 primes^3 [ + ] cartesian-map concat primes^4 [ + ] cartesian-map concat - [ n <= ] filter remove-duplicates length ; + [ n <= ] filter members length ; PRIVATE> :: euler087 ( -- answer ) - 50000000 prime-triples ; + 50,000,000 prime-triples ; + +SOLUTION: euler087