嘿到目前为止我得到的解决方案给了我一些整数的预期结果,但不满足测试用例,(codewars https://www.codewars.com/kata/find-the-divisors/train/php)
function divisors($integer) {
$array = [];
if($integer<=1)
return false;
for($i = 2 ; $i <= sqrt($integer) ; $i++){
if($integer% $i == 0){
array_push($array,$i);
}
}
if (empty($array)){
return $integer. " is prime";
}else{
return implode( ", ", $array );
}
}
任何帮助表示赞赏,现在我收到以下错误
3' does not match expected type "array"
慕丝7291255
猛跑小猪