使用递归算法计算斐波那契数列的第30位数字。
<?php function test($i){ if($i == 1 || $i == 2){ return 1; } return test($i - 1) + test($i - 2); } echo test(30); ?>
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://haodehen.cn/did7598
使用递归算法计算斐波那契数列的第30位数字。
<?php function test($i){ if($i == 1 || $i == 2){ return 1; } return test($i - 1) + test($i - 2); } echo test(30); ?>
上一篇: 页面浮动广告代码
下一篇:Apache本地二级域名配置