#K74247. Digit Root Sorting
Digit Root Sorting
Digit Root Sorting
You are given a list of integers. Your task is to compute the digit root of each number and then sort these digit roots in ascending order. The digit root of a number is defined as:
$$ \text{dr}(n) = \begin{cases} n, &\text{if } n < 10,\\ \text{dr}\Big(\sum_{digits}\, n\Big), &\text{if } n \ge 10, \end{cases} $$
In other words, repeatedly sum the digits of a number until only a single-digit number remains.
The input starts with an integer N which represents the count of numbers. The subsequent line consists of N space-separated integers. Your program must compute their digit roots, sort the resulting values in non-decreasing order, and output them.
inputFormat
The first line contains an integer N representing the number of integers. The second line contains N space-separated integers.
outputFormat
Output a single line containing the sorted digit roots separated by a single space.## sample
5
38 15 122 4 91
1 2 4 5 6
</p>