#C653. Add Digits Until a Single Digit
Add Digits Until a Single Digit
Add Digits Until a Single Digit
Given a non-negative integer (n), repeatedly add its digits until the result is a single-digit number. This process involves summing the digits of (n); if the sum has more than one digit, the process is repeated until a single-digit number is obtained. For example, (38) becomes (3+8=11) and then (1+1=2), so the answer is (2).
inputFormat
The input consists of a single non-negative integer (n) provided via standard input.
outputFormat
Output a single integer which is the result of repeatedly summing the digits of (n) until a single-digit number is obtained.## sample
38
2