update
This commit is contained in:
parent
1f1ad49427
commit
6f050a029e
2496 changed files with 37609 additions and 3031 deletions
14
Task/Multifactorial/Perl/multifactorial.pl
Normal file
14
Task/Multifactorial/Perl/multifactorial.pl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{ # <-- 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