8 lines
212 B
Text
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)]
|
|
].
|