Welcome

Shad Gregory's Blog

FizzBuzz

11/22/2022 12:32 :: clojure

If you're going to interview, you better know FizzBuzz:

(defn fizzbuzz [n]
  (doseq [x (range 1 n)]
    (cond
      (and (zero? (mod x 5))
           (zero? (mod x 3))) (prn "FizzBuzz")
      (zero? (mod x 3)) (prn "Fizz")
      (zero? (mod x 5)) (prn "Buzz")
      :else (prn x))))
(fizzbuzz 10)