Skip to content

Instantly share code, notes, and snippets.

@mamboking
Created August 30, 2011 13:40
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 mamboking/1180903 to your computer and use it in GitHub Desktop.
Save mamboking/1180903 to your computer and use it in GitHub Desktop.
Hamming Number Generator
;;Hamming Numbers
(defn hamming-generator
([] (hamming-generator (sorted-set 1)))
([some-set] (let [n (first some-set)
s (disj some-set n)]
(cons n
(lazy-seq (hamming-generator
(conj s (* n 2) (* n 3) (* n 5))))))))
(def hamming-numbers (take 1000 (hamming-numbers)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment