#K75372. Digital Root Calculation

    ID: 34405 Type: Default 1000ms 256MiB

Digital Root Calculation

Digital Root Calculation

Given a non-negative integer \( n \), the digital root is the value obtained by an iterative process of summing its digits until a single-digit number is produced. Formally, define the function \( f(n) \) as follows:

[ f(n)=\begin{cases} n, & \text{if } n<10,\[6pt] f\Bigl(\sum_{i}d_{i}\Bigr), & \text{if } n\ge10, \end{cases} ]

Your task is to compute the digital root of the given number \( n \).

Example:

  • Input: 16       Output: 7
  • Input: 942      Output: 6
  • Input: 493193 Output: 2

inputFormat

The input consists of a single line containing a non-negative integer \( n \).

outputFormat

Output a single digit which is the digital root of the given number \( n \).

## sample
0
0

</p>