14. Sum of Digits
EasyMath~6 min
Return the sum of the digits of a non-negative whole number.
For example, 1234 gives 1 + 2 + 3 + 4 = 10.
Examples
Example 1
- Input:
- n = 1234
- Output:
- 10
Example 2
- Input:
- n = 0
- Output:
- 0
Constraints
0 <= n <= 1000000000n is an integer.