| 1 |
\documentclass{article} |
| 2 |
\usepackage{lisp-on-tex} |
| 3 |
\lispinterp{% |
| 4 |
(\define \sq (\lambda (\n) (\* \n \n))) |
| 5 |
(\define \fact (\lambda (\n) (\lispif (\= \n :0) :1 (\* \n (\fact (\- \n :1)))))) |
| 6 |
} |
| 7 |
\newcommand\sq[1]{\lispinterp{(\texprint (\sq :#1))}} |
| 8 |
\newcommand\fact[1]{\lispinterp{(\texprint (\fact :#1))}} |
| 9 |
|
| 10 |
\begin{document} |
| 11 |
\section{Factorials and Squares} |
| 12 |
\begin{center} |
| 13 |
\begin{tabular}{r||rr}\hline\hline |
| 14 |
$n$ & $n!$ & $n^2$ \\ |
| 15 |
\hline |
| 16 |
1 & \fact{1} & \sq{1} \\ |
| 17 |
2 & \fact{2} & \sq{2} \\ |
| 18 |
3 & \fact{3} & \sq{3} \\ |
| 19 |
4 & \fact{4} & \sq{4} \\ |
| 20 |
5 & \fact{5} & \sq{5} \\ |
| 21 |
6 & \fact{6} & \sq{6} \\ |
| 22 |
7 & \fact{7} & \sq{7} \\ |
| 23 |
8 & \fact{8} & \sq{8} \\ |
| 24 |
9 & \fact{9} & \sq{9} \\ |
| 25 |
10 & \fact{10} & \sq{10} \\ |
| 26 |
11 & \fact{11} & \sq{11} \\ |
| 27 |
\hline |
| 28 |
\end{tabular} |
| 29 |
\end{center} |
| 30 |
\end{document} |