Skip to content

Instantly share code, notes, and snippets.

@dbalan
Created September 5, 2017 13:18
Show Gist options
  • Save dbalan/89f13dd86e77509eb51ac12d1ee31991 to your computer and use it in GitHub Desktop.
Save dbalan/89f13dd86e77509eb51ac12d1ee31991 to your computer and use it in GitHub Desktop.
(ns fizzbuzz.core
(:gen-class))
(defn series [arg] (take arg (range)))
(defn fizzbuzz [arg]
(cond
(and (= 0 (mod arg 3)) (= 0 (mod arg 5))) "fizzbuzz"
(= 0 (mod arg 3)) "fizz"
(= 0 (mod arg 5)) "buzz"
:else arg))
(defn parse-int [s]
(Integer. (re-find #"[0-9]*" s)))
(defn fizzseries [s]
(map fizzbuzz (series s)))
(defn -main
"I don't do a whole lot ... yet."
[& args]
(let [input (read-line)]
(map print (fizzseries (parse-int input)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment