Factorial: Difference between revisions
Content added Content deleted
(→Insitux: implementation) |
imported>Rowsety Moid No edit summary |
||
Line 362: | Line 362: | ||
endif. |
endif. |
||
endform.</syntaxhighlight> |
endform.</syntaxhighlight> |
||
=={{header|Acornsoft Lisp}}== |
|||
===Recursive=== |
|||
<syntaxhighlight lang="lisp">(defun factorial (n) |
|||
(cond ((zerop n) 1) |
|||
(t (times n (factorial (sub1 n)))))) |
|||
</syntaxhighlight> |
|||
===Iterative=== |
|||
<syntaxhighlight lang="lisp">(defun factorial (n (result . 1)) |
|||
(loop |
|||
(until (zerop n) result) |
|||
(setq result (times n result)) |
|||
(setq n (sub1 n)))) |
|||
</syntaxhighlight> |
|||
=={{header|Action!}}== |
=={{header|Action!}}== |