5 lines
156 B
Text
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]
|
|
].
|