<?php function tribonacci($signature, $n) { if($n==3){ return $signature; }elseif($n>0 && $n<3){ return array_slice($signature,0,$n); }elseif($n==0){ return []; } $newarr = array_slice($signature, -3); $new = array_sum($newarr); array_push($signature,$new); $n--; // var_dump($signature); // var_dump($n); tribonacci($signature, $n); } var_dump(tribonacci([1,1,1],10));
慕莱坞8333017
蛋大人
蛋大人