LISP program to calculate the square and cube of numbers
kw.lisp
(write-line "+--------+---------+------------+") (write-line "|Numbers | Squares | Cubes |") (write-line "+--------+---------+------------+") (dotimes(n 11) (format t " ~d ~d ~d ~%"n(* n n)(* n(* n n)))) (write-line "+--------+---------+------------+")
Output
kodingwindow@kw:~$ clisp kw.lisp +--------+---------+------------+ |Numbers | Squares | Cubes | +--------+---------+------------+ 0 0 0 1 1 1 2 4 8 3 9 27 4 16 64 5 25 125 6 36 216 7 49 343 8 64 512 9 81 729 10 100 1000 +--------+---------+------------+ kodingwindow@kw:~$
Comments and Reactions
What Next?
LISP program to find the min and max of two numbers
LISP program to swap the given numbersLISP Control StatementsAdvertisement