RosettaCodeData/Task/Factorial/Slate/factorial-2.slate

6 lines
156 B
Text
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
n@(Integer traits) factorial2
[
n isNegative ifTrue: [error: 'Negative inputs to factorial are invalid.'].
(1 upTo: n by: 1) reduce: [|:a :b| a * b]
].