September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,3 @@
func factorial_recursive(n) {
n == 0 ? 1 : (n * __FUNC__(n-1))
}

View file

@ -0,0 +1,3 @@
func factorial_reduce(n) {
1..n -> reduce({|a,b| a * b }, 1)
}

View file

@ -0,0 +1,5 @@
func factorial_iterative(n) {
var f = 1
{|i| f *= i } << 2..n
return f
}

View file

@ -0,0 +1 @@
say 5!

View file

@ -1,19 +0,0 @@
# Recursive
func factorial_recursive(n) {
n == 0 ? 1 : (n * __FUNC__(n-1));
}
# Iterative with Array#reduce
func factorial_reduce(n) {
1..n -> reduce('*');
}
# Iterative with Block#repeat
func factorial_iterative(n) {
var f = 1;
{|i| f *= i } * n;
return f;
}
# Built-in Number#factorial:
say 5!;