A386641 Triangle read by row: T(n,k) is the number of the k-th eliminated person in a variant of the Josephus problem in which one person is skipped, then one is eliminated, then two people are skipped, then the next person is eliminated and so on.
1, 2, 1, 2, 3, 1, 2, 1, 4, 3, 2, 5, 1, 3, 4, 2, 5, 4, 1, 6, 3, 2, 5, 3, 4, 1, 6, 7, 2, 5, 1, 8, 4, 6, 3, 7, 2, 5, 9, 7, 8, 4, 1, 3, 6, 2, 5, 9, 6, 4, 8, 7, 3, 1, 10, 2, 5, 9, 4, 1, 3, 8, 10, 11, 6, 7, 2, 5, 9, 3, 11, 10, 1, 8, 4, 7, 6, 12, 2, 5, 9, 1, 10, 7, 8, 13, 12, 6, 4, 11, 3, 2, 5, 9, 14, 8, 4, 3, 7, 13
Offset: 1
Examples
Consider 4 people in a circle. Initially, person number 1 is skipped, and person 2 is eliminated. The remaining people are now in order 3, 4, 1. Then, two people are skipped, and person 1 is eliminated. The remaining people are in order 3, 4. Now, three people are skipped and person 4 is eliminated. Person 3 is eliminated last. Thus, the fourth row of the triangle is 2,1,4,3. The triangle begins as follows: 1; 2, 1; 2, 3, 1; 2, 1, 4, 3; 2, 5, 1, 3, 4; 2, 5, 4, 1, 6, 3; 2, 5, 3, 4, 1, 6, 7; 2, 5, 1, 8, 4, 6, 3, 7; 2, 5, 9, 7, 8, 4, 1, 3, 6;
Programs
-
Python
def row(n): c, i, J = 1, 0, list(range(1, n+1)) output = [] while len(J) > 1: i = (i + c) % len(J) q = J.pop(i) output.append(q) c = c + 1 output.append(J[0]) return output print([e for n in range(1,15) for e in row(n)])
Comments