#C2135. Sum of Digits Until Single Digit
Sum of Digits Until Single Digit
Sum of Digits Until Single Digit
You are given a non-negative integer \(n\). Your task is to repeatedly compute the sum of the digits of \(n\) until the result becomes a single digit. Formally, define the function \(f(n)\) as:
\(f(n) = \begin{cases} n, & \text{if } n < 10 \\ f(s(n)), & \text{if } n \ge 10 \end{cases}\)
where \(s(n) = \sum_{i=1}^{k} d_i\) and \(d_i\) represents each digit of \(n\). For example, for \(n = 38\), we have \(3 + 8 = 11\) and then \(1 + 1 = 2\), so \(f(38) = 2\>.
inputFormat
The input consists of a single integer \(n\) provided via standard input.
outputFormat
Output a single integer which is the final single-digit result obtained after repeatedly summing the digits of \(n\).
## sample38
2
</p>