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

9 lines
212 B
Plaintext

n@(Integer traits) factorial
"The standard recursive definition."
[
n isNegative ifTrue: [error: 'Negative inputs to factorial are invalid.'].
n <= 1
ifTrue: [1]
ifFalse: [n * ((n - 1) factorial)]
].