Created
July 14, 2014 21:10
-
-
Save ircmaxell/a96ee55d364402199423 to your computer and use it in GitHub Desktop.
Ackersum
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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