I can only think about a bit faster version: 46555ms => 23846ms for 20
(defn smallest-multiple-of-1-to-n [n] (let [divisors (range 2 (inc n))] (loop [i n] (if (loop [d 2] (cond (> d n) true (not= 0 (mod i d)) false :else (recur (inc d)))) i (recur (inc i)))))) I am not familiar with how Clojure's numeric works. There should be a faster way of doing it in Clojure. On Sunday, February 3, 2013 10:28:09 AM UTC+8, Alexandros Bantis wrote: > > Hello all. I'm working through the Project Euler problems in Java, > Scala, & Clojure (trying to learn all three?!?). I notice that for one > particular problem, I use--more or less--a similar algorithm for all > three, but the clojure code runs about 20-30 times slower than the > java/scala versions. Does anyone have any idea why this might be? It > strikes me that it might have something to do with every? but I don't > know because I'm a newbie with Clojure. > > > http://stackoverflow.com/questions/14668272/what-can-i-do-to-speed-up-this-code > > > thanks, > > alex > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.