In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of October 26th
(this exercise will still be available for submission after that deadline, but without couting towards your grade)
[to understand the context of this problem, you should read the class #03 exercise sheet]
Have you ever looked at a number and thought, "What if I could just add up all its digits and see what I get?"
Write a program that takes a positive integer num as input and calculates the sum of its digits. For example, if the input number is 123
, the output should be 1 + 2 + 3 = 6
.
The input consists of a single integer num.
The output should be a single integer representing the sum of the digits of the input number.
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ num ≤ 109 | The input number must be a positive integer |
Example Input 1 | Example Output 1 |
781 |
16 |
Example Input 2 | Example Output 2 |
16250301 |
18 |