#K47257. Digital Root Calculation
Digital Root Calculation
Digital Root Calculation
You are given a non-negative integer \(n\). Your task is to compute its digital root, which is obtained by repeatedly summing the digits of the number until only a single-digit value remains.
For example, for \(n = 1234\), the calculation proceeds as follows:
[ 1234 \rightarrow 1+2+3+4 = 10 \rightarrow 1+0 = 1 ]
The answer in this case is 1. Note that when \(n = 0\), the digital root is 0.
inputFormat
The input consists of a single line containing a non-negative integer \(n\). You can assume \(n\) fits in a standard integer type.
outputFormat
Output a single line with the digital root of \(n\), which is the single-digit result of repeatedly summing its digits.
## sample1234
1