Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
|
|
@ -0,0 +1,21 @@
|
|||
func fib(n) is cached {
|
||||
n < 2 ? 1
|
||||
: (fib(n-1) + fib(n-2));
|
||||
}
|
||||
|
||||
func zeckendorf(n) {
|
||||
n == 0 && return '0';
|
||||
var i = 1;
|
||||
++i while (fib(i) <= n);
|
||||
gather {
|
||||
while (--i > 0) {
|
||||
var f = fib(i);
|
||||
f > n ? (take '0')
|
||||
: (take '1'; n -= f);
|
||||
}
|
||||
}.join('');
|
||||
}
|
||||
|
||||
range(0, 20).each { |n|
|
||||
printf("%4d: %8s\n", n, zeckendorf(n))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue