Arggh. I've been trying to create an implementation of Ackermann's function in PHP (for Project Euler, if you must know), and it works for small(ish) numbers, but if I enter anything relatively high like (m,n) -> (6,6), the program doesn't work. Any ideas (code below)? Thanks!

Code: Select all

`<?php`

function ackermann($x,$y)

{

if ($x != 0)

{

if ($x > 0 && $y == 0)

{

return ackermann($x-1,1);

}

if ($x > 0 && $y > 0)

{

return ackermann($x-1,ackermann($x, $y-1));

}

}

else

{

return $y + 1;

}

}

echo ackermann(m,n);

//m,n is replaced by the values you want to find the Ackermann value for.

?>