Skip to content

Instantly share code, notes, and snippets.

@serialhex
Created September 12, 2016 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save serialhex/f2e1b91584fc419b03fc63b020aafd34 to your computer and use it in GitHub Desktop.
Save serialhex/f2e1b91584fc419b03fc63b020aafd34 to your computer and use it in GitHub Desktop.
FizzBuzz...
(defun fizzbuzz (n)
(fizzbuzz-helper 1 n ))
(defun fizzbuzz-helper (n x)
(case (mod n 15)
(0 (princ "FizzBuzz"))
((3 6 9 12) (princ "Fizz"))
((5 10) (princ "Buzz"))
(otherwise (princ n)))
(fresh-line)
(if (< n x)
(fizzbuzz-helper (+ 1 n) x)))
(defun fizzbuzz (n)
(fizzbuzz-helper 1 n ))
(defun fizzbuzz-helper (n x)
(cond
((= 0 (mod n 15)) (princ "FizzBuzz"))
((= 0 (mod n 3)) (princ "Fizz"))
((= 0 (mod n 5)) (princ "Buzz"))
(otherwise (princ n)))
(fresh-line)
(if (< n x)
(fizzbuzz-helper (+ 1 n) x)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment