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

8 lines
212 B
Text

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)]
].