Embercode
✕
OperatorsCoding problems

Operators: coding problems

Write a program that reads the input and prints the answer. Run checks it against every test, including hidden ones.

0 of 8 solved

  • A cashier wants a quick check digit. For a receipt number, add up all of its decimal digits. The number can be as large as a long, so an int is not enough.

    **Constraints:** 0 <= n <= 10^18.

    Use % to read the last digit and / to drop it.

    Input. One integer n.

    Output. One integer: the sum of the decimal digits of n.

    Example 1 input

    4825
    

    Output

    19
    

    Example 2 input

    1000000000000000000
    

    Output

    1