next up previous contents index
Next: Calculating the sum of Up: Examples for recursion Previous: Examples for recursion   Contents   Index


Calculating the faculty of a number


\begin{lstlisting}[language=Scm]{}
(define fac
(lambda(n)
(if (equaln n one)
one
(mult n (fac (sub n one))))))
\end{lstlisting}


\begin{lstlisting}[language=Scm]{}
(ndisp! (fac five))
--> 120
\end{lstlisting}


domain access counter Georg P. Loczewski 2004-03-05