Digital Root (Math)

Repeatedly add the digits of n until a single digit remains. Print it.

Input: One non-negative integer (up to 18 digits).

Output: One digit.

Difficulty: Easy. Write your answer in the browser editor, run the examples, then submit it against hidden tests. Python and JavaScript are free; other languages are part of licode Club.

Hint

  • Loop while the number has more than one digit.

More Math practice