Skip to content

Instantly share code, notes, and snippets.

@cypher
Created March 17, 2010 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cypher/335281 to your computer and use it in GitHub Desktop.
Save cypher/335281 to your computer and use it in GitHub Desktop.
(defn euler5 []
(+ 1
(last
(take-while (fn [w] (not
(every? #(zero? (rem w %)) (range 1 20) )))
(range 1 1000000000000 1)))))
;; Takes about 5 mins on my machine
(defn euler5b []
(first (drop-while
(fn [n] (not (every? #(zero? (rem n %)) (range 1 21))))
(iterate inc 1))))
;; Takes about 10 seconds
(defn euler5c []
(first
(drop-while
(fn [n] (not (every? #(zero? (rem n %)) (range 10 20))))
(iterate #(+ 20 %) 20))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment