使用递归算阶乘

<?php
//使用递归求5的阶乘
function five($n)
{
    if ($n == 1) { //
        return 1;
    }
    $res = $n * five($n -1); //算阶乘的算法
    return $res;
}

echo five(5);

递归就是自己的函数调用自己

原文地址:https://www.cnblogs.com/xm666/p/11185930.html