RosettaCodeData/Task/Factorial/Slate/factorial-2.slate
2023-07-01 13:44:08 -04:00

5 lines
156 B
Text

n@(Integer traits) factorial2
[
n isNegative ifTrue: [error: 'Negative inputs to factorial are invalid.'].
(1 upTo: n by: 1) reduce: [|:a :b| a * b]
].