FizzFizz by hebiyan

(defun show (n)
  (labels ((inner (m rv)
               ((zerop (mod m 3))
                (inner (floor m 3) (format nil "~aFizz" rv)))
               ((zerop (mod m 5))
                (inner (floor m 5) (format nil "~aBuzz" rv)))
      ((zerop (mod n 3))
       (inner (floor n 3) "Fizz"))
      ((zerop (mod n 5))
       (inner (floor n 5) "Buzz"))
       (format nil "~a" n)))))

(defun fizzfizz (start stop)
  (loop for n from start upto stop
       do (format t "~a~%" (show n))))

(fizzfizz 1 100)

Note that non-ascii characters in the above source code will be escaped (such as \x9f).


return to the top page