Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
8
Task/Factorial/Slate/factorial-1.slate
Normal file
8
Task/Factorial/Slate/factorial-1.slate
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
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)]
|
||||
].
|
||||
5
Task/Factorial/Slate/factorial-2.slate
Normal file
5
Task/Factorial/Slate/factorial-2.slate
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
n@(Integer traits) factorial2
|
||||
[
|
||||
n isNegative ifTrue: [error: 'Negative inputs to factorial are invalid.'].
|
||||
(1 upTo: n by: 1) reduce: [|:a :b| a * b]
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue