#K6431. Generate Palindromic Sequence
Generate Palindromic Sequence
Generate Palindromic Sequence
Given a positive integer n, generate a sequence that starts at 1, increases by 1 until it reaches n, and then decreases by 1 until it reaches 1. The sequence can be formally expressed as: \(1, 2, \ldots, n-1, n, n-1, \ldots, 2, 1\).
For example, when n = 3, the output should be: 1 2 3 2 1
.
inputFormat
Input consists of a single integer n (1 (\leq) n (\leq) 105), read from standard input.
outputFormat
Output a single line containing the sequence with each number separated by a single space.## sample
5
1 2 3 4 5 4 3 2 1