Embercode
✕
JavaScript basicsCoding problems

JavaScript basics: coding problems

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

0 of 7 solved

  • Maya is checking a ticket number. She adds up all its digits to see whether the total is small enough to be lucky. Given a non-negative whole number n, print the sum of its digits.

    Constraints: 0 <= n <= 1000000000.

    Input. One line with the integer n.

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

    Example 1 input

    4821
    

    Output

    15
    

    Example 2 input

    7
    

    Output

    7