2016 Update
This commit is contained in:
parent
948b86eafa
commit
dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions
|
|
@ -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";
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue