Pseudocode Compiler
Practice

Sum of Digits

MEDIUMArithmetic

Read a positive integer. Output the sum of its digits.

Input: A positive integer. Output: The sum of its digits.

Example:

Input:  123
Output: 6

(because 1 + 2 + 3 = 6)

Premium is coming soon. All grading features are currently unlocked.

Sample Test Cases

Test 1: 1+2+3
Inputs: 123
Expected: 6
Test 2: 9+9+9+9
Inputs: 9999
Expected: 36
Test 3: 1+0+0
Inputs: 100
Expected: 1
Press Ctrl+Enter to run your code
or Ctrl+Shift+Enter to grade