Created
October 29, 2009 03:07
-
-
Save anonymous/221079 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Project Euler, problem 92 | |
(use 'clojure.contrib.math) | |
(defn digits-of [n] | |
(map read-string (map str (str n)))) | |
(defn chain [n] | |
(let [sum (apply + (map #(expt % 2) (digits-of n)))] | |
(lazy-seq | |
(cons n (chain sum))))) | |
(defn is-in? [xs n] | |
(some #(= % n) xs)) | |
(println (count (filter #(is-in? (chain %) 89) (range 1 10000000))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment