Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
18
Task/Factorial/Ecstasy/factorial.ecstasy
Normal file
18
Task/Factorial/Ecstasy/factorial.ecstasy
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
module ShowFactorials {
|
||||
static <Value extends IntNumber> Value factorial(Value n) {
|
||||
assert:arg n >= Value.zero();
|
||||
return n <= Value.one() ? n : n * factorial(n-Value.one());
|
||||
}
|
||||
|
||||
@Inject Console console;
|
||||
void run() {
|
||||
// 128-bit test
|
||||
UInt128 bigNum = 34;
|
||||
console.print($"factorial({bigNum})={factorial(bigNum)}");
|
||||
|
||||
// 64-bit test
|
||||
for (Int i : 10..-1) {
|
||||
console.print($"factorial({i})={factorial(i)}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue