Skip to content

Instantly share code, notes, and snippets.

@gnab
Created June 24, 2013 19:58
Show Gist options
  • Save gnab/5853050 to your computer and use it in GitHub Desktop.
Save gnab/5853050 to your computer and use it in GitHub Desktop.
FizzBuzz solved using condp function
(defn FizzBuzz
"Returns 'Fizz', 'Buzz' or 'FizzBuzz' if n is divisible by
3, 5 or both, respectively, or else just n."
[n]
(condp #(zero? (mod %2 %1)) n
15 "FizzBuzz"
3 "Fizz"
5 "Buzz"
(str n)))
(->>
(range 1 16)
(map FizzBuzz)
(println))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment