Lets say for length 5, I want to generate the following sequence:
1 2 3 2 1
but for length 6, I want to generate the following:
1 2 3 3 2 1
such that the sequence is palindromic and there is always a repeating middle for even length.
Is there a general f(n, m) where n = desired length of sequence that gives correct mth item from the sequence?
Other examples:
length 7: 1 2 3 4 3 2 1
length 8: 1 2 3 4 4 3 2 1
You can use an expression such as:
The left part in the $\min$ function runs through the first $n$ positive integers in ascending order, the right part in descending order. Taking the least values gives your sequence.