Skip to content

Instantly share code, notes, and snippets.

@namenu
Last active May 26, 2021 01:52
Show Gist options
  • Save namenu/688c4015130a346a24ca84889f3207c7 to your computer and use it in GitHub Desktop.
Save namenu/688c4015130a346a24ca84889f3207c7 to your computer and use it in GitHub Desktop.
FizzBuzz
(defn divisible? [divisor number]
(zero? (mod number divisor)))
(defn fizzbuzz [n]
(case [(divisible? 3 n) (divisible? 5 n)]
[true false] "Fizz"
[false true] "Buzz"
[true true] "FizzBuzz"
n))
(doseq [n (range 1 101)]
(println (fizzbuzz n)))
(defn fizzybuzzy [n]
(case (mod (* n n n n) 15)
6 "Fizz"
10 "Buzz"
0 "FizzBuzz"
1 n))
(= (map fizzbuzz (range 1 101))
(map fizzybuzzy (range 1 101)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment