# Next line in triangular sequence

$$\small \begin{array}{c} 1\\ 1 & 2\\ 1 & 3 & 2\\ 1 & 3 & 2 & 4\\ 1 & 5 & 2 & 4 & 3\\ 1 & 4 & 2 & 6 & 3 & 5\\ 1 & 6 & 2 & 5 & 3 & 7 & 4\\ 1 & 5 & 2 & 7 & 3 & 6 & 4 & 8\\ 1 & 9 & 2 & 6 & 3 & 8 & 4 & 7 & 5\\ 1 & 6 & 2 & 10 & 3 & 7 & 4 & 9 & 5 & 8\\ 1 & 9 & 2 & 7 & 3 & 11 & 4 & 8 & 5 & 10 & 6\\ 1 & 7 & 2 & 10 & 3 & 8 & 4 & 12 & 5 & 9 & 6 & 11\\ 1 & 12 & 2 & 8 & 3 & 11 & 4 & 9 & 5 & 13 & 6 & 10 & 7\\ 1 & 8 & 2 & 13 & 3 & 9 & 4 & 12 & 5 & 10 & 6 & 14 & 7 & 11\\ 1 & 12 & 2 & 9 & 3 & 14 & 4 & 10 & 5 & 13 & 6 & 11 & 7 & 15 & 8\\ 1 & 9 & 2 & 13 & 3 & 10 & 4 & 15 & 5 & 11 & 6 & 14 & 7 & 12 & 8 & 16\\ 1 & 17 & 2 & 10 & 3 & 14 & 4 & 11 & 5 & 16 & 6 & 12 & 7 & 15 & 8 & 13 & 9\\ 1 & 10 & 2 & 18 & 3 & 11 & 4 & 15 & 5 & 12 & 6 & 17 & 7 & 13 & 8 & 16 & 9 & 14\\ 1 & 15 & 2 & 11 & 3 & 19 & 4 & 12 & 5 & 16 & 6 & 13 & 7 & 18 & 8 & 14 & 9 & 17 & 10\\ 1 & 11 & 2 & 16 & 3 & 12 & 4 & 20 & 5 & 13 & 6 & 17 & 7 & 14 & 8 & 19 & 9 & 15 & 10 & 18 \end{array}$$

What is the next line in this number triangle sequence?

What is the $100$th line?

The $n$th line represents the order of elimination in the Josephus problem with $n$ people and $k=2$. In other words, the numbers are written in order, skipping one spot every time and wrapping around.

The next line is 1,19,2,12,3,17,4,13,5,21,6,14,7,18,8,15,9,20,10,16,11.

The $100$th line is 1,51,2,76,3,52,4,99,5,53,6,77,7,54,8,89,9,55,10,78,11,56,12,95,13,57,14,79,15,58,16,90,17,59,18,80,19,60,20,98,21,61,22,81,23,62,24,91,25,63,26,82,27,64,28,96,29,65,30,83,31,66,32,92,33,67,34,84,35,68,36,100,37,69,38,85,39,70,40,93,41,71,42,86,43,72,44,97,45,73,46,87,47,74,48,94,49,75,50,88.

For nth line, you place n empty slots in a row. Start filling numbers sequentially starting from 1 into the slots by skipping an empty slot every time you place a number. Whenever you reach the end of the line, you wrap around and keep filling the empty slots keeping the above rule in mind. This will the give next line as:

1, 19, 2, 12, 3, 17, 4, 13, 5, 21, 6, 14, 7, 18, 8, 15, 9, 20, 10, 16, 11

Similarly, the 100th line would be:

1, 51, 2, 76, 3, 52, 4, 99, 5, 53, 6, 77, 7, 54, 8, 89, 9, 55, 10, 78, 11, 56, 12, 95, 13, 57, 14, 79, 15, 58, 16, 90, 17, 59, 18, 80, 19, 60, 20, 98, 21, 61, 22, 81, 23, 62, 24, 91, 25, 63, 26, 82, 27, 64, 28, 96, 29, 65, 30, 83, 31, 66, 32, 92, 33, 67, 34, 84, 35, 68, 36, 100, 37, 69, 38, 85, 39, 70, 40, 93, 41, 71, 42, 86, 43, 72, 44, 97, 45, 73, 46, 87, 47, 74, 48, 94, 49, 75, 50, 88