Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
15
Task/Ackermann-function/Perl/ackermann-function-4.pl
Normal file
15
Task/Ackermann-function/Perl/ackermann-function-4.pl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use Memoize; memoize('ack2');
|
||||
use bigint try=>"GMP";
|
||||
|
||||
sub ack2 {
|
||||
my ($m, $n) = @_;
|
||||
$m == 0 ? $n + 1 :
|
||||
$m == 1 ? $n + 2 :
|
||||
$m == 2 ? 2*$n + 3 :
|
||||
$m == 3 ? 8 * (2**$n - 1) + 5 :
|
||||
$n == 0 ? ack2($m-1, 1)
|
||||
: ack2($m-1, ack2($m, $n-1));
|
||||
}
|
||||
print "ack2(3,4) is ", ack2(3,4), "\n";
|
||||
print "ack2(4,1) is ", ack2(4,1), "\n";
|
||||
print "ack2(4,2) has ", length(ack2(4,2)), " digits\n";
|
||||
Loading…
Add table
Add a link
Reference in a new issue