#K48897. Digital Root Computation

    ID: 28522 Type: Default 1000ms 256MiB

Digital Root Computation

Digital Root Computation

Given a non-negative integer \( n \), compute its digital root. The digital root of a number is obtained by repeatedly summing its digits until a single-digit number is produced. This can be computed using the formula: \( digital\_root(n) = \begin{cases} 0 & \text{if } n = 0 \\ 1 + ((n-1) \mod 9) & \text{if } n \neq 0 \end{cases} \).

Your task is to implement a program that reads an integer from standard input and prints its digital root to standard output.

inputFormat

The input consists of a single non-negative integer \( n \) given via standard input.

outputFormat

Output a single integer representing the digital root of \( n \) to standard output.

## sample
9875
2

</p>