#C12146. Repeated Digital Sum

    ID: 41541 Type: Default 1000ms 256MiB

Repeated Digital Sum

Repeated Digital Sum

Given a non-negative integer ( n ), the task is to repeatedly calculate the sum of its digits until the result is a single-digit number. This operation is sometimes called the digital root. For example, for ( n = 38 ), the sum of digits is ( 3 + 8 = 11 ); since 11 is not a single-digit, we sum its digits again ( 1 + 1 = 2 ). Hence, the output is 2. The process stops when the number becomes less than 10.

inputFormat

The input is provided via standard input. It consists of a single integer ( n ), where ( n \geq 0 ).

outputFormat

The output should be printed to standard output and must be the single-digit result (the digital root) obtained by repeatedly summing the digits of ( n ).## sample

5
5