DEV Community

loading...

Discussion on: Project Euler #5 - Finding the Smallest Multiple

Collapse
_andy_lu_ profile image
Andy Lu

Clojure

(defn euler-5 [x]
  (let [gcd (fn [x y] (if (zero? y) x (recur y (mod x y))))
        lcm (fn [x y] (/ (* x y) (gcd x y)))]
    (reduce lcm (range 1 (inc x)))))