Skip to content

Instantly share code, notes, and snippets.

Created April 3, 2010 21:10
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)
(if (not (zero? (mod n (first s))))
(recur (rest s))))))
(defn euler-5
"What is the smallest number that is evenly divisible by all of the numbers
from 1 to 20?"
(let [nums (range 1 (+ 1 limit))]
(loop [n 20]
(if (evenly-divisible? n nums)
(recur (inc n))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment