Skip to content

Instantly share code, notes, and snippets.

@ircmaxell
Created July 14, 2014 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ircmaxell/a96ee55d364402199423 to your computer and use it in GitHub Desktop.
Save ircmaxell/a96ee55d364402199423 to your computer and use it in GitHub Desktop.
Ackersum
<?php
function ackersum($a, $b) {
if ($a == 0) {
return $b;
} elseif ($b == 0) {
return $a;
} elseif ($a == 1) {
return $b + 1;
}
return ackersum(1, (ackersum($a - 1, $b) + ackersum($a, $b - 1)) / 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment