Skip to content

Instantly share code, notes, and snippets.

@shortsightedsid
Last active March 24, 2019 19:00
Show Gist options
  • Save shortsightedsid/1c7427b0e9f97810e8a1 to your computer and use it in GitHub Desktop.
Save shortsightedsid/1c7427b0e9f97810e8a1 to your computer and use it in GitHub Desktop.
Print Multiplication Tables
;; Print Multiplication Tables
;;
;; This demonstrates CL's format function and it's ability
;; to print out Roman Numerals, Numbers in Words etc..
;;
;; Unlikely to be ever used!
(defun multiplication-table (number)
(loop for i from 1 below 12
do (format t "~10<~@r~;times~> ~:d = ~r~%" i number (* i number))
collect i into list-of-i
collect (* i number) into list-of-j
finally (return (values list-of-i list-of-j))))
@priyadarshan
Copy link

priyadarshan commented Aug 14, 2018

An example:

CL-USER 1 > (multiplication-table 7)
I    times 7 = seven
II   times 7 = fourteen
III  times 7 = twenty-one
IV   times 7 = twenty-eight
V    times 7 = thirty-five
VI   times 7 = forty-two
VII  times 7 = forty-nine
VIII times 7 = fifty-six
IX   times 7 = sixty-three
X    times 7 = seventy
XI   times 7 = seventy-seven
(1 2 3 4 5 6 7 8 9 10 11)
(7 14 21 28 35 42 49 56 63 70 77)

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