/*
* @lc app=leetcode.cn id=2180 lang=typescript
*
* [2180] 统计各位数字之和为偶数的整数个数
*/
// @lc code=start
function countEven(num: number): number {}
// @lc code=end
function countEven(num: number): number {
let res = 0
for (let i = 1; i <= num; i++) {
let x = i,
ans = 0
while (x) {
ans += x % 10
x = Math.floor(x / 10)
}
if (ans % 2 === 0) res++
}
return res
}
test.each([
{ input: { num: 4 }, output: 2 },
{ input: { num: 30 }, output: 14 },
])('input: num = $input.num', ({ input: { num }, output }) => {
expect(countEven(num)).toEqual(output)
})