<?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));
4 回答
- 4 回答
- 0 关注
- 3483 浏览
添加回答
举报
0/150
提交
取消