PHP练习-爬楼梯问题

2020-08-14 23:56 By "Powerless" 2654 1 2

思路分析

斐波那契数列 + 递归思想

function climb ($num)
{
    if($num == 1 || $num == 2){
        $c = $num;
    }else{
        $c = climb($num - 1) + climb($num - 2);
    }
    return $c;
}
echo climb(12);

结果输出:233

评 论

辛福 2 2020-08-29 12:09
1HmnFIrk

Others Discussion

  • 前端知识体系精简-Css
    Posted on 2018-03-28 18:34
  • Linux工具 - NM目标文件格式分析
    Posted on 2019-04-24 10:29
  • ACID原则
    Posted on 2020-12-17 16:36
  • 浏览器访问网站经历的步骤-Html
    Posted on 2018-11-28 18:48
  • HTTP头中隐藏PHP版本号
    Posted on 2021-01-11 16:38
  • Composer 异常 [ErrorException]
    Posted on 2019-11-25 17:55
  • TCP协议的特性
    Posted on 2019-04-26 16:46
  • 能创建多少个 TCP 连接?
    Posted on 2021-08-02 16:00