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 A384774 #19 Jul 30 2025 04:24:13 %S A384774 1,2,1,2,5,3,2,5,9,8,3,12,6,10,4,16,12,16,5,9,20,10,6,22,21,23,7,27, %T A384774 13,21,8,30,23,20,9,16,31,17,10,31,24,35,11,34,20,27,12,28,34,49,13, %U A384774 23,31,24,14,49,55,34,15,35,27,59,16,44,38,60,17,30,53,31 %N A384774 Elimination order of the first person in a variation of the Josephus problem in which first three people are skipped, then one is eliminated, repeating until all n people are eliminated. %C A384774 a(4k-1) = k %C A384774 a(n) = A384770(n,1). %e A384774 Consider n = 4 people. The first person eliminated is number 4. This leaves the remaining people in order 1, 2, 3. On the second step, we eliminate person number 1, implying that the order of elimination of the first person is 2: a(4) = 2. %p A384774 A384774 := proc(n::integer) %p A384774 local plist,eli,skip,ptr ; %p A384774 plist := [seq(i,i=1..n)] ; %p A384774 eli :=1 ; %p A384774 skip := 3; %p A384774 ptr := 0 ; %p A384774 while true do %p A384774 ptr := modp(ptr+skip,nops(plist)) ; %p A384774 if op(ptr+1,plist) = 1 then %p A384774 return eli ; %p A384774 end if; %p A384774 plist := subsop(ptr+1=NULL,plist) ; %p A384774 eli := eli+1 ; %p A384774 end do: %p A384774 end proc: %p A384774 seq(A384774(n),n=1..100) ; # _R. J. Mathar_, Jul 30 2025 %o A384774 (Python) %o A384774 def a(n): %o A384774 c, i, J = 1, 0, list(range(1, n+1)) %o A384774 while len(J) > 0: %o A384774 i = (i + 3)%len(J) %o A384774 q = J.pop(i) %o A384774 if q == 1: return c %o A384774 c = c+1 %o A384774 print([a(n) for n in range(1, 71)]) %Y A384774 Cf. First column of A384770. %Y A384774 Cf. A225381, A384772, A088333. %K A384774 nonn %O A384774 1,2 %A A384774 _Tanya Khovanova_, _Nathan Sheffield_, and the MIT PRIMES STEP junior group, Jun 09 2025