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.

A382355 A version of the Josephus problem: a(n) is the surviving integer under the skip-eliminate-skip version of the elimination process.

Original entry on oeis.org

1, 1, 1, 4, 3, 6, 3, 6, 9, 3, 6, 9, 12, 1, 4, 7, 10, 13, 16, 19, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34, 37, 40, 43, 46, 49, 52, 55, 58, 61, 64, 67, 70, 3, 6
Offset: 1

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Mar 22 2025

Keywords

Comments

This variation of the Josephus problem is related to under-down-under card dealing.

Examples

			Consider 4 people in a circle in order 1,2,3,4. In the first round, person 1 is skipped, then person 2 is eliminated, then person 3 is skipped. Now people are in order 4,1,3. In the second round, person 4 is skipped, person 1 is eliminated, and person 3 is skipped. Now people are in order 4,3. In the third round person 3 is eliminated. Person 4 is freed. Thus, a(4) = 4.
		

Crossrefs

Programs

  • Python
    def J(n,A):
        l=[]
        for i in range(n):
            l.append(i+1)
        index = 0
        P=[]
        for i in range(n):
            index+=A[i]
            index=index%len(l)
            P.append(l[index])
            l.pop(index)
        return P
    def invPerm(p):
        inv = []
        for i in range(len(p)):
            inv.append(None)
        for i in range(len(p)):
            inv[p[i]-1]=i+1
        return inv
    def survivor(n, A):
        return J(n, A)[n-1]
    def UDU(n):
        return [1] + [2 for i in range(n)]
    seq = []
    for i in range(1,20):
        seq += [survivor(i, UDU(i))]
    print(", ".join([str(v) for v in seq]))
    
  • Python
    def a(n):
        c, i, J = 1, 0, list(range(1, n+1))
        while len(J) > 1:
            i = (i + 1)%len(J)
            q = J.pop(i)
            i = (i + 1)%len(J) # skip the third
        return J[0]
    print([a(n) for n in range(1, 73)]) # Michael S. Branicky, Mar 24 2025