8 lines
219 B
Text
8 lines
219 B
Text
def fact:
|
|
def _fact:
|
|
# Input: [accumulator, counter]
|
|
if .[1] <= 1 then .
|
|
else [.[0] * .[1], .[1] - 1]| _fact
|
|
end;
|
|
# Extract the accumulated value from the output of _fact:
|
|
[1, .] | _fact | .[0] ;
|