Module: (Java) Nested loops


Problem

4 /8


Numeric root

Problem

The digital root of a natural number is obtained as follows. Add up all the digits of the given number. The process is repeated until the result is a single-digit number, which is called the digital root of the number.

Input: The input to the program is a natural number n<=109.
Output: Print its digital root.

Examples
# Input Output
1 10 1
2 888 6