(defn next-term [n]
(if (= (mod n 2) 0) (/ n 2)
(inc (* n 3))))
(defn count-terms [n]
(if (= 1 n) 1
(inc (count-terms (next-term n)))))
(time
(let [pair (juxt identity count-terms)
pairs (map pair (range 1 100000))]
(println (first (apply max-key second pairs)))))
It looks even? is the culprit here. The code above executes in < 1 sec on my
machine.
So it looks like even? needs to repaired to account for the numeric changes.
David
--
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