Created
September 12, 2016 20:19
-
-
Save serialhex/f2e1b91584fc419b03fc63b020aafd34 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
(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))) |
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
(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