Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active June 30, 2024 14:37
Show Gist options
  • Save trikitrok/74f8cdb860b7b1b70571 to your computer and use it in GitHub Desktop.
Save trikitrok/74f8cdb860b7b1b70571 to your computer and use it in GitHub Desktop.
(ns fizz_buzz.core)
(defn fizz-buzz-number [num]
(let [is-multiple-of? (fn [n] (= 0 (rem num n)))
a-multiple-of-3 (is-multiple-of? 3)
a-multiple-of-5 (is-multiple-of? 5)
a-multiple-of-both (and a-multiple-of-3
a-multiple-of-5)]
(cond
a-multiple-of-both "FizzBuzz"
a-multiple-of-3 "Fizz"
a-multiple-of-5 "Buzz"
:else (str num))))
(defn fizz-buzz [coll]
(clojure.string/join
\space
(map fizz-buzz-number coll)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment