Skip to content

Instantly share code, notes, and snippets.

Created September 17, 2011 01:15
Show Gist options
  • Save anonymous/1223483 to your computer and use it in GitHub Desktop.
Save anonymous/1223483 to your computer and use it in GitHub Desktop.
;; fronx's solution to Happy numbers
;; https://4clojure.com/problem/86
(fn [n]
(loop [seen #{}
n n]
(let [v (->> n
str vec
(map #(- (int %) 48))
(map #(* % %))
(reduce +))]
(cond
(= v 1) true
(contains? seen v) false
:else (recur (conj seen v) v)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment