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.

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.

Original entry on oeis.org

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, 13, 21, 8, 30, 23, 20, 9, 16, 31, 17, 10, 31, 24, 35, 11, 34, 20, 27, 12, 28, 34, 49, 13, 23, 31, 24, 14, 49, 55, 34, 15, 35, 27, 59, 16, 44, 38, 60, 17, 30, 53, 31
Offset: 1

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Jun 09 2025

Keywords

Comments

a(4k-1) = k
a(n) = A384770(n,1).

Examples

			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.
		

Crossrefs

Cf. First column of A384770.

Programs

  • Maple
    A384774 := proc(n::integer)
        local plist,eli,skip,ptr ;
        plist := [seq(i,i=1..n)] ;
        eli :=1 ;
        skip := 3;
        ptr := 0 ;
        while true do
            ptr := modp(ptr+skip,nops(plist)) ;
            if op(ptr+1,plist) = 1 then
                return eli ;
            end if;
            plist := subsop(ptr+1=NULL,plist) ;
            eli := eli+1 ;
        end do:
    end proc:
    seq(A384774(n),n=1..100) ; # R. J. Mathar, Jul 30 2025
  • Python
    def a(n):
        c, i, J = 1, 0, list(range(1, n+1))
        while len(J) > 0:
            i = (i + 3)%len(J)
            q = J.pop(i)
            if q == 1: return c
            c = c+1
    print([a(n) for n in range(1, 71)])