One idea that I had was to inline the factoring logic into twice-
composite. Who cares about the factors? We just want to know if there
are two or not:
(defn twice-composite? [n]
(loop [ps prime-seq
tmp n
p-count 0]
(if (< 2 p-count)
false
(if (= 1 tmp)
(= 2 p-count)
(let [p (first ps)]
(if (divides? tmp p)
(recur ps (quot tmp p) (inc p-count))
(recur (rest ps) tmp p-count))))))
)
But this lead to even slower code.
On Nov 3, 2:15 pm, Mark Engelberg <[email protected]> wrote:
> Your Clojure implementation of your particular approach is reasonable,
> but you need a cleverer approach. I'll send you a hint offline.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en