cp's OEIS Frontend

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.

A382356 Elimination order of the first person in a variation of the Josephus problem, where there are n people total. During each round the first person is skipped, the second is eliminated and the third person is skipped. Then the process repeats.

This page as a plain text file.
%I A382356 #9 Apr 05 2025 23:41:53
%S A382356 1,2,3,2,4,4,3,5,7,4,10,9,5,14,9,6,10,15,7,18,21,8,19,14,9,15,24,10,
%T A382356 21,28,11,23,19,12,20,26,13,31,28,14,36,24,15,25,43,16,47,39,17,44,29,
%U A382356 18,30,44,19,40,50,20,42,34,21,35,45,22,57,47,23,55,39,24
%N A382356 Elimination order of the first person in a variation of the Josephus problem, where there are n people total. During each round the first person is skipped, the second is eliminated and the third person is skipped. Then the process repeats.
%C A382356 This elimination process is related to under-down-under card dealing.
%C A382356 a(3k-2) = k.
%e A382356 Consider n people. Four people are in order 1,2,3,4. In the first round, the first person is skipped, the second person is eliminated, and the third person is skipped. Now people are ordered 4,1,3. In the second round, person 4 is skipped, and person 1 is eliminated. Thus, person 1 is eliminated in the second round and a(4) = 2.
%o A382356 (Python)
%o A382356 def T(n, A):
%o A382356     return invPerm(J(n,A))
%o A382356 def J(n,A):
%o A382356     l=[]
%o A382356     for i in range(n):
%o A382356         l.append(i+1)
%o A382356     index = 0
%o A382356     P=[]
%o A382356     for i in range(n):
%o A382356         index+=A[i]
%o A382356         index=index%len(l)
%o A382356         P.append(l[index])
%o A382356         l.pop(index)
%o A382356     return P
%o A382356 def invPerm(p):
%o A382356     inv = []
%o A382356     for i in range(len(p)):
%o A382356         inv.append(None)
%o A382356     for i in range(len(p)):
%o A382356         inv[p[i]-1]=i+1
%o A382356     return inv
%o A382356 def firstPersonElimOrder(n, A):
%o A382356     return T(n, A)[0]
%o A382356 def UDU(n):
%o A382356     return [1] + [2 for i in range(n)]
%o A382356 seq = []
%o A382356 for i in range(1,88):
%o A382356     seq += [firstPersonElimOrder(i, UDU(i))]
%o A382356 print(", ".join([str(v) for v in seq]))
%o A382356 (Python)
%o A382356 def a(n):
%o A382356     c, i, J = 1, 0, list(range(1, n+1))
%o A382356     while len(J) > 0:
%o A382356         i = (i + 1)%len(J)
%o A382356         q = J.pop(i)
%o A382356         if q == 1: return c
%o A382356         i = (i + 1)%len(J) # skip the third
%o A382356         c = c+1
%o A382356 print([a(n) for n in range(1, 71)]) # _Michael S. Branicky_, Mar 24 2025
%Y A382356 Cf. A006257, A225381, A321298, A378635, A382354, A382355, A382358.
%K A382356 nonn
%O A382356 1,2
%A A382356 _Tanya Khovanova_, _Nathan Sheffield_, and the MIT PRIMES STEP junior group, Mar 22 2025