RosettaCodeData/Task/Factorial/0815/factorial.0815

12 lines
380 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
}:r: Start reader loop.
|~ Read n,
#:end: if n is 0 terminates
>= enqueue it as the initial product, reposition.
}:f: Start factorial loop.
x<:1:x- Decrement n.
{=*> Dequeue product, position n, multiply, update product.
^:f:
{+% Dequeue incidental 0, add to get Y into Z, output fac(n).
<:a:~$ Output a newline.
^:r: