Last active
May 26, 2021 01:52
-
-
Save namenu/688c4015130a346a24ca84889f3207c7 to your computer and use it in GitHub Desktop.
FizzBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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