#K76277. Collatz Sequence
Collatz Sequence
Collatz Sequence
Given a positive integer \( n \) (\(1 \le n \le 1000\)), generate its Collatz sequence. The Collatz sequence is formed as follows: start with \( n \), then, if the current term is even, divide it by 2; if it is odd, multiply it by 3 and add 1. Repeat this process until the number 1 is reached. The sequence should be output as a comma-separated list.
For example, if \( n = 6 \), the sequence is: 6, 3, 10, 5, 16, 8, 4, 2, 1.
inputFormat
The input is provided via standard input. It consists of a single integer \( n \), where \(1 \le n \le 1000\).
outputFormat
The output should be written to standard output as a single line containing the Collatz sequence starting from \( n \) and ending with 1. The numbers in the sequence should be separated by commas without extra spaces.
## sample6
6,3,10,5,16,8,4,2,1