Home >php教程 >PHP源码 >Ack函数,php

Ack函数,php

WBOY
WBOYOriginal
2016-06-08 17:31:391472browse
<script>ec(2);</script>




function Ack($m,$n)
{
   if($m==0)
   {
      return $n+1;
   }
    else
   {
     if($n==0)
     {
       return Ack($m-1,1);
     }
       else
     {
      return Ack($m-1,Ack($m,$n-1));
     }
   }
}
//--------------------------------------//
for($i=0;$i{
    for($j=0;$j    {
        printf("-%5d-",Ack($i,$j));
    }
       printf("n");
}
?>


-    1--    2--    3-
-    2--    3--    4-
-    3--    5--    7-

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn