Skip to content

Instantly share code, notes, and snippets.

@rnkn
Last active September 26, 2015 03:34
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 rnkn/7dffd266310aa346842e to your computer and use it in GitHub Desktop.
Save rnkn/7dffd266310aa346842e to your computer and use it in GitHub Desktop.
Emacs fizzbuzz function
(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)))))
@jsscclr
Copy link

jsscclr commented May 15, 2015

But what is the use case???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment