Sum of Even Digits
Given a non-negative integer n, return the sum of the even digits in its decimal representation. Zero is an even digit, but adding it does not change the sum.…
Given a non-negative integer `n`, return the sum of the even digits in its decimal representation. Zero is an even digit, but adding it does not change the sum. For `n = 0`, return `0`.
- `0 <= n <= 10^9` - The input has no leading zeroes except for the value `0` itself.
Example 1: input n = 482731; output 14. The even digits are 4, 8, and 2, whose sum is 14.
Example 2: input n = 97531; output 0. There are no even digits.
Example 3: input n = 204; output 6. The even digits 2, 0, and 4 sum to 6.
Category: Math. Topic: math. Difficulty: Easy. Patterns: math.