2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,8 +1,14 @@
use 5.10.0;
sub ng {
state %g;
my ($n, $d, $key) = ( @_[0], @_[1], $n.'ng'.$d);
if (!$g{$key}) {$g[$key] = ($n <= $d+1)? $n : ng($n-$d,$d)*$n}
return $g[$key];
{ # <-- scoping the cache and bigint clause
my @cache;
use bigint;
sub mfact {
my ($s, $n) = @_;
return 1 if $n <= 0;
$cache[$s][$n] //= $n * mfact($s, $n - $s);
}
}
for my $s (1 .. 10) {
print "step=$s: ";
print join(" ", map(mfact($s, $_), 1 .. 10)), "\n";
}