class Solution {
/**
* @param Integer $num
* @return Integer
*/
function countEven(int $num)
{
$sum = 0;
for ($i = 2; $i <= $num; $i++) {
if ($this->getNext($i)%2 == 0) {
$sum++;
}
}
return $sum;
}
public function getNext(int $n)
{
$sum = 0;
while($n>0){
$sum += $n%10;
$n = floor($n/10);
}
return $sum;
}
}
力扣第2180题
猜你喜欢
转载自blog.csdn.net/weixin_42475906/article/details/129048438
今日推荐
周排行