6. Sum of Digits
Foundation1000 ms256 MBSolved by 0%
Read a non-negative integer and print the sum of its digits.
For example, the digits of 4207 are 4, 2, 0 and 7, which add up to 13.
Constraints - `0 ≤ n ≤ 1000000000000000000`
Input
A single line containing one integer n.
Output
Print one integer, the sum of the digits.
Input4207
Output13
Noteis the worked example from the statement
Input9
Output9
Noteis a single digit, so the answer is the number itself
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.