Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created October 3, 2012 01:22
Show Gist options
  • Select an option

  • Save jcromartie/3824366 to your computer and use it in GitHub Desktop.

Select an option

Save jcromartie/3824366 to your computer and use it in GitHub Desktop.
(defn fizzbuzz
[n]
(condp #(= 0 (mod %2 %1)) n
15 "FizzBuzz"
3 "Fizz"
5 "Buzz"
n))
(deftest test-fizzbuzz
(is (= [1 2 "Fizz" 4 "Buzz" "Fizz" 7 8 "Fizz" "Buzz" 11 "Fizz" 13 14 "FizzBuzz"]
(map fizzbuzz (range 1 16)))))
(defn run-fizzbuzz
[max]
(doseq [n (range 1 (inc max))]
(println (fizzbuzz n))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment