Last active
September 26, 2015 03:34
-
-
Save rnkn/7dffd266310aa346842e to your computer and use it in GitHub Desktop.
Emacs fizzbuzz function
This file contains hidden or 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 () | |
"For numbers 1 through 100: if the number is divisible by 3 and | |
5 print FizzBuzz; if the number is divisible by 3 print Fizz; if | |
the number is divisible by 5 print Buzz; else, print the number." | |
(interactive) | |
(let ((n 1)) | |
(while (<= n 100) | |
(cond ((and (= (% n 3) 0) | |
(= (% n 5) 0)) | |
(insert "FizzBuzz" ?\n)) | |
((= (% n 5) 0) | |
(insert "Fizz" ?\n)) | |
((= (% n 3) 0) | |
(insert "Buzz" ?\n)) | |
((insert (number-to-string n) ?\n))) | |
(setq n (1+ n))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
But what is the use case???