Skip to content

Instantly share code, notes, and snippets.

@mowen mowen/euler-5.clj
Created Apr 3, 2010

Embed
What would you like to do?
(ns martin)
(defn evenly-divisible?
"Is N evenly-divisible by all of the numbers in SEQ?"
[n seq]
(loop [s seq]
;; TODO: Find out how to do 'cond' in Clojure
(if (empty? s)
true
(if (not (zero? (mod n (first s))))
false
(recur (rest s))))))
(defn euler-5
"What is the smallest number that is evenly divisible by all of the numbers
from 1 to 20?"
[limit]
(let [nums (range 1 (+ 1 limit))]
(loop [n 20]
(if (evenly-divisible? n nums)
n
(recur (inc n))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.