#C7003. Digit Sum Sequence
Digit Sum Sequence
Digit Sum Sequence
You are given two integers \(N\) and \(M\). Your task is to generate a sequence of \(M\) numbers where the first term is the sum of the digits of \(N\) and each subsequent term is the sum of the digits of the previous term.
The digit sum of a number \(n\) is defined as follows:
For example, if \(N = 987654321\) and \(M = 3\), then:
- The first term is \(\text{ds}(987654321)=45\).
- The second term is \(\text{ds}(45)=9\).
- The third term is \(\text{ds}(9)=9\).
Print the sequence (\(M\) numbers) separated by a single space.
inputFormat
The input consists of a single line containing two integers \(N\) and \(M\) separated by a space. \(N\) is a positive integer, and \(M\) is the number of terms to generate in the sequence.
outputFormat
Output exactly \(M\) numbers separated by a space. These numbers represent the sequence of digit sums computed as described.
## sample123 5
6 6 6 6 6