All problems
Sum of Digits
easyPythonMathStrings
A membership desk validates card numbers with an old paper-era check: add up the digits of the number and compare the total against the figure printed on the card. The clerk types in the card number and the tool shows the total.
Task: Read the card number and print the total of its digits.
Input
A single line holding one non-negative integer n of 1 to 18 digits. There is no sign, no spaces and no leading zeros.
Output
One line holding a single integer: the digits of n added together.
Example:
Input:
1234
Output:
10
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in