题目为:一个猴子守着一堆桃子,第一天吃了一半又多吃了一个,第二天一样,到第十天就剩下一个桃子,请问原来有几个桃子?
202003090206罗的解题思路是这样的:
echo'';
function get_peach($number, $day) {
if ($day >= 10) {
return $number;
}
return get_peach (($number + 1) * 2, $day + 1);
}
$number = 1;
$number = get_peach ($number, 1);
print_r ($number);
?>
运行结果如图所示:
-202003090206罗
来源地址:https://blog.csdn.net/m0_71722908/article/details/127955235