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.

A381048 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, and the second and the third person are eliminated. Then the process repeats.

This page as a plain text file.
%I A381048 #17 May 04 2025 17:27:14
%S A381048 1,2,3,3,4,6,5,6,9,7,8,11,9,10,14,11,12,18,13,14,19,15,16,22,17,18,27,
%T A381048 19,20,27,21,22,30,23,24,35,25,26,35,27,28,38,29,30,44,31,32,43,33,34,
%U A381048 46,35,36,54,37,38,51,39,40,54,41,42,61,43,44,59,45,46,62,47
%N A381048 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, and the second and the third person are eliminated. Then the process repeats.
%C A381048 This elimination process is related to the under-down-down card dealing.
%F A381048 a(3k+1) = 2k+1; a(3k-1) = 2k.
%e A381048 Consider four people in order 1,2,3,4. In the first round, the first person is skipped and the second and the third persons are eliminated. Now people are ordered 4,1. In the second round, person 4 is skipped, and person 1 is eliminated. Thus, person 1 is eliminated third and a(4) = 3.
%o A381048 (Python)
%o A381048 def a(n):
%o A381048     i, J, out, c = 0, list(range(1, n+1)), [], 0
%o A381048     while len(J) > 1:
%o A381048         i = (i + 1)%len(J)
%o A381048         q = J.pop(i)
%o A381048         c += 1
%o A381048         if q == 1:
%o A381048             return c
%o A381048         i = i%len(J)
%o A381048         if len(J) > 1:
%o A381048             q = J.pop(i)
%o A381048             c += 1
%o A381048             if q == 1:
%o A381048                 return c
%o A381048     return c+1
%o A381048 print([a(n) for n in range(1, 71)]) # _Michael S. Branicky_, Apr 28 2025
%Y A381048 Cf. A006257, A007494, A225381, A321298, A378635, A337191,  A381049, A382528.
%K A381048 nonn
%O A381048 1,2
%A A381048 _Tanya Khovanova_, _Nathan Sheffield_, and the MIT PRIMES STEP junior group, Apr 14 2025