Problems > Sum of Digits

Sum of Digits

Difficulty: 800 2000 ms 128 MB

math implementation

Print the sum of the decimal digits of N.

Input: one integer N.

Output: the digit sum of N.

Constraints:

  • 0 ≤ N ≤ 1018

Sample Tests

Input 1
1234
Output 1
10
Input 2
999999999999999999
Output 2
162

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.