function ack($m, $n) { if ($m == 0) { return $n + 1; } if ($n == 0) { return ack($m - 1, 1); } return ack($m - 1, ack($m, $n - 1)); }
function notifications($data) { //debug $n = (array) $data; debug("payload: " . print_r($n, true)); //define response $response = null; //multiple notifications if (is_array($data->Notification)) { $response = array(); for ($i = 0; $i < count($data->Notification); $i++) { array_push($response, ack(process_notification($data->Notification[$i]))); } } else { $response = ack(process_notification($data->Notification)); } return $response; }
function ackermann($n = 7) { $r = ack(3, $n); }
function ackermann($n = 7) { $r = ack(3, $n); print "ack(3,{$n}): {$r}\n"; }
function ack($m, $n){ if($m == 0) return $n+1; if($n == 0) return ack($m-1, 1); return ack($m - 1, ack($m, ($n - 1))); }