Non-averaging Sequence

Puneet Kumar
Nov 5 · 2 min read

You have to arrange the numbers between 1-N in such a fashion such that if we choose subsequence of length 3 then they should not form Arithmetic Progression.

it means that if we choose ai,aj,ak then

Example 
N=10
1 9 5 3 7 2 10 6 4 8

here is the list of arrangements for N=1 to N=15.

1;
1, 2;
1, 3, 2;
1, 3, 2, 4;
1, 5, 3, 2, 4;
1, 5, 3, 2, 6, 4;
1, 5, 3, 7, 2, 6, 4;
1, 5, 3, 7, 2, 6, 4, 8;
1, 9, 5, 3, 7, 2, 6, 4, 8;
1, 9, 5, 3, 7, 2, 10, 6, 4, 8;
1, 9, 5, 3, 11, 7, 2, 10, 6, 4, 8;
1, 9, 5, 3, 11, 7, 2, 10, 6, 4, 12, 8;
1, 9, 5, 13, 3, 11, 7, 2, 10, 6, 4, 12, 8;
1, 9, 5, 13, 3, 11, 7, 2, 10, 6, 14, 4, 12, 8;
1, 9, 5, 13, 3, 11, 7, 15, 2, 10, 6, 14, 4, 12, 8;

The 2n-th row is the concatenation of row n, after multiplying each term by 2 and subtracting 1, with row n, after multiplying each term by 2.

Example:- 2n=6 so n=3
2n-th row : 1*2-1, 3*2-1, 2*2-1, 1*2, 3*2, 2*2
so the final 2n-th row will be : 1, 5, 3, 2, 6, 4

Similarly, The (2n-1)-th row is the concatenation of row n, after multiplying each term by 2 and subtracting 1, with row n-1, after multiplying each term by 2.

Example:- 2n-1=7 so n=4 and n-1=3
(2n-1)-th row : 1*2-1, 3*2-1, 2*2-1, 4*2-1, 1*2, 3*2, 2*2
so the final (2n-1)-th row will be : 1, 5, 3, 7, 2, 6, 4

Here is the program for the above logic.

source=https://oeis.org/A088370

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade