Sum of Digits
Easy
Math
Math
Given a positive integer, return the sum of its digits.
Constraints
1 ≤ n ≤ 10^18
Examples
Example 1:
Input: 123
Output: 6
Example 2:
Input: 999
Output: 27
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console