Logo
IconChallenge
Icon
IconProblem
IconSolutions
IconSubmissions

Count Integers With Even Digit Sum

XPChallenge Points: 10
levelLevel: Easy

You are given a positive integer num.
You must count how many numbers from 1 to num (inclusive) have a digit sum that is even.

The digit sum of a number is found by adding all the digits in it.
Return how many numbers satisfy this condition.

Example 1:

Input: num = 1

Output: 0

Explanation:

Only number is 1 → digit sum is 1 → not even.

Example 2:

Input: num = 10

Output: 4

Explanation:

Numbers with even digit sum → 2, 4, 6, 8, 10

to Continue
like
dislike

Accepted:

Submission:

IconReport an issue
Icon
IconCode
IconYou need toto run or submitYou need toto run or submit
IconTest Case
IconTest Result