Factorial: Difference between revisions
Content added Content deleted
(→Iterative: factorial(0) == 1) |
m (→[[Factorial function#ALGOL 68]]: use a more authentic DO OD loop.) |
||
Line 32: | Line 32: | ||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |
||
===Iterative=== |
===Iterative=== |
||
PROC factorial = (INT |
PROC factorial = (INT upb n)LONG LONG INT:( |
||
INT |
LONG LONG INT z := 1; |
||
FOR n TO upb n DO z *:= n OD; |
|||
WHILE n>1 DO |
|||
n -:= 1; |
|||
z *:= n |
|||
OD; |
|||
z |
z |
||
) |
); |
||
===Recursive=== |
===Recursive=== |
||
PROC factorial = (INT n)LONG LONG INT: |
PROC factorial = (INT n)LONG LONG INT: |