#K69067. Digit Root Calculation
Digit Root Calculation
Digit Root Calculation
Given a non-negative integer ( n ), the task is to calculate its digit root. The digit root is obtained by repeatedly summing the digits of ( n ) until a single digit is obtained. A mathematical formula to obtain the digit root for ( n > 0 ) is given by
and if ( n = 0 ) then the digit root is 0.
Your program should read the integer from standard input and output its digit root to standard output.
inputFormat
The input consists of a single line containing a non-negative integer ( n ).
outputFormat
Output a single integer, which is the digit root of the input integer.## sample
9875
2