Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Created February 11, 2015 11:50
Show Gist options
  • Save trikitrok/9c8f49fe418330a58682 to your computer and use it in GitHub Desktop.
Save trikitrok/9c8f49fe418330a58682 to your computer and use it in GitHub Desktop.
(defn- happy? [n visited]
(if (contains? visited n)
false
(if (= n 1)
true
(let [ndigits (decompose-in-digits n)
sum-of-squares (apply + (map square ndigits))]
(recur sum-of-squares (conj visited n))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment