Sum of Digits

EasyMath

Description

Given a non-negative integer n, return the sum of its decimal digits.

Examples

Input:n = 38
Output:11
Explanation:

Adding the individual digits of 38 together totals 11.

Input:n = 0
Output:0
Explanation:

Adding the individual digits of 0 together totals 0.

Input:n = 99999
Output:45
Explanation:

Adding the individual digits of 99999 together totals 45.

Constraints

  • 0 ≤ n ≤ 10⁹

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.