兔子繁殖

$count = rabbit(12);
echo $count;

function rabbit($month){
   $count = 1;
   $lastmonthcount = 0;
   for ($i=1; $i <= $month; $i++) {
      $current = $count - $lastmonthcount;
      $lastmonthcount = $current;
      $count = $count + $current;
   }
   return $count;
}

发表评论

电子邮件地址不会被公开。 必填项已用*标注