This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A386641 #12 Aug 08 2025 17:57:00 %S A386641 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, %T A386641 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, %U A386641 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 %N 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. %C A386641 The numbers 1 through n are arranged in a circle. The process starts at position 1. Initially, the first number is skipped, and the next number is eliminated. Then, two numbers are skipped, and the next one is eliminated. Then, three numbers are skipped, and so on. The process repeats until no numbers remain. %C A386641 This variation of the Josephus problem can equivalently be described in terms of the AP card dealing, where the cards of a deck are dealt by alternately x cards from the top "under", and then dealing the next card "down". Here, x starts as 1, and is increased by 1 with every dealt card. In particular, T(n,k) is the k-th card dealt in the AP dealing if the deck begins in order 1,2,3,...,n. %C A386641 The freed person is A291317(n). %F A386641 T(n,k) = A000096(k), when n >= A000096(k). %e A386641 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. %e A386641 The triangle begins as follows: %e A386641 1; %e A386641 2, 1; %e A386641 2, 3, 1; %e A386641 2, 1, 4, 3; %e A386641 2, 5, 1, 3, 4; %e A386641 2, 5, 4, 1, 6, 3; %e A386641 2, 5, 3, 4, 1, 6, 7; %e A386641 2, 5, 1, 8, 4, 6, 3, 7; %e A386641 2, 5, 9, 7, 8, 4, 1, 3, 6; %o A386641 (Python) %o A386641 def row(n): %o A386641 c, i, J = 1, 0, list(range(1, n+1)) %o A386641 output = [] %o A386641 while len(J) > 1: %o A386641 i = (i + c) % len(J) %o A386641 q = J.pop(i) %o A386641 output.append(q) %o A386641 c = c + 1 %o A386641 output.append(J[0]) %o A386641 return output %o A386641 print([e for n in range(1,15) for e in row(n)]) %Y A386641 Cf. A000096, A291317, A386639, A386643. %Y A386641 Cf. A321298 (classical elimination process). %K A386641 nonn,tabl %O A386641 1,2 %A A386641 _Tanya Khovanova_, _Nathan Sheffield_, and the MIT PRIMES STEP junior group, Jul 27 2025