#K58307. Magic Sequence
Magic Sequence
Magic Sequence
Given a positive integer \( n \), generate its magic sequence as follows:
- Start the sequence with the initial number \( n \).
- While \( n \) has two or more digits (i.e. \( n \ge 10 \)), replace \( n \) with the sum of its digits, and append the result to the sequence.
For example, if \( n = 29 \), the sequence is generated as:
29 \( \to \) 2+9=11 \( \to \) 1+1=2, yielding the sequence: 29 11 2
.
Your task is to read the input number from standard input, compute the magic sequence, and output all the numbers in the sequence on a single line separated by single spaces.
inputFormat
The input consists of a single line containing one positive integer \( n \) (\( 1 \le n \le 10^{18} \)).
outputFormat
Output the magic sequence corresponding to the input number. Print the sequence on one line, with each number separated by a single space.
## sample5
5
</p>