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:~$ 
Advertisement