#K68287. Digital Root Sequence

    ID: 32831 Type: Default 1000ms 256MiB

Digital Root Sequence

Digital Root Sequence

Given a list of integers, compute the digital root of each integer. The digital root of a number is obtained by repeatedly summing its digits until a single digit remains. Formally, for any integer \(n\), the digital root \(dr(n)\) is defined as follows:

\[ dr(n) = \begin{cases} n, & \text{if } n \le 9, \\ dr\Big(\sum \text{digits of } n\Big), & \text{if } n \ge 10. \end{cases} \]

Your task is to compute the digital root for each provided integer and output them separated by a single space.

inputFormat

The first line of input contains an integer (n) representing the number of integers. The second line contains (n) space-separated integers.

outputFormat

Output a single line containing (n) space-separated integers, where each integer is the digital root of the corresponding input integer.## sample

4
1 2 3 9
1 2 3 9