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 A381591 #20 Mar 26 2025 22:02:08 %S A381591 1,1,2,4,2,6,6,3,9,6,4,7,11,5,11,15,6,13,11,7,12,16,8,23,18,9,22,16, %T A381591 10,17,31,11,27,30,12,35,21,13,22,37,14,30,35,15,32,26,16,27,35,17,47, %U A381591 37,18,53,31,19,32,47,20,57,56,21,51,36,22,37,65,23,49,70 %N A381591 Elimination order of the first person in a variation of the Josephus problem, where there are n people total and two people are skipped each time. %C A381591 a(3k-1) = k. %e A381591 Consider n = 4 people. The first person eliminated is number 3. This leaves the remaining people in order 4, 1, 2. The second person eliminated is number 2. Thus, the remaining people in order 4, 1. The next person eliminated is number 4. On the fourth step, person number 1 is eliminated, implying that the order of elimination of the first person is 4: a(4) = 4. %o A381591 (Python) %o A381591 def UUD(n): %o A381591 return invPerm(UUDES(n)) %o A381591 def UUDES(n): %o A381591 l=[] %o A381591 for i in range(n): %o A381591 l.append(i+1) %o A381591 index = 0 %o A381591 P=[] %o A381591 for i in range(n): %o A381591 index+=2 %o A381591 index=index%len(l) %o A381591 P.append(l[index]) %o A381591 l.pop(index) %o A381591 return P %o A381591 def invPerm(p): %o A381591 inv = [] %o A381591 for i in range(len(p)): %o A381591 inv.append(None) %o A381591 for i in range(len(p)): %o A381591 inv[p[i]-1]=i+1 %o A381591 return inv %o A381591 sequence = [] %o A381591 for i in range(1, 71): %o A381591 sequence += [str(UUD(i)[0])] %o A381591 print(", ".join(sequence)) %o A381591 (Python) %o A381591 def a(n): %o A381591 c, i, J = 1, 0, list(range(1, n+1)) %o A381591 while len(J) > 0: %o A381591 i = (i + 2)%len(J) %o A381591 q = J.pop(i) %o A381591 if q == 1: return c %o A381591 c = c+1 %o A381591 print([a(n) for n in range(1, 71)]) # _Michael S. Branicky_, Mar 24 2025 %Y A381591 Cf. A006257, A054995, A225381, A321298, A378635, A380195, A008585, A381591 A381667. %K A381591 nonn %O A381591 1,3 %A A381591 _Tanya Khovanova_, _Nathan Sheffield_, and the MIT PRIMES STEP junior group, Mar 02 2025