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.

Showing 1-4 of 4 results.

A381049 Triangle T(n,k) read by rows: where T(n,k) is the number of the k-th eliminated person in the variation of the Josephus elimination process for n people, where one person is skipped and two people are eliminated.

Original entry on oeis.org

1, 2, 1, 2, 3, 1, 2, 3, 1, 4, 2, 3, 5, 1, 4, 2, 3, 5, 6, 4, 1, 2, 3, 5, 6, 1, 4, 7, 2, 3, 5, 6, 8, 1, 7, 4, 2, 3, 5, 6, 8, 9, 4, 7, 1, 2, 3, 5, 6, 8, 9, 1, 4, 10, 7, 2, 3, 5, 6, 8, 9, 11, 1, 7, 10, 4, 2, 3, 5, 6, 8, 9, 11, 12, 4, 7, 1, 10, 2, 3, 5, 6, 8, 9, 11, 12, 1, 4, 10, 13, 7
Offset: 1

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Apr 14 2025

Keywords

Comments

This Josephus problem is related to under-down-down card dealing.
The n-th row has n elements.
In this variation of the Josephus elimination process, the numbers 1 through n are arranged in a circle. A pointer starts at position 1. With each turn, the pointer skips one number and the next two numbers are eliminated. The process repeats until no numbers remain. This sequence represents the triangle T(n, k), where n is the number of people in the circle, and T(n, k) is the elimination order of the k-th number in the circle.

Examples

			Consider 4 people in a circle. Initially, person number 1 is skipped and persons number 2 and 3 are eliminated. The remaining people are now in order 4, 1. Then 4 is skipped and 1 is eliminated. Then, 4 is eliminated. Thus, the fourth row of the triangle is 2, 3, 1, 4, the order of elimination.
Triangle begins;
1;
2, 1;
2, 3, 1;
2, 3, 1, 4;
2, 3, 5, 1, 4;
2, 3, 5, 6, 4, 1;
2, 3, 5, 6, 1, 4, 7;
2, 3, 5, 6, 8, 1, 7, 4;
2, 3, 5, 6, 8, 9, 4, 7, 1;
		

Crossrefs

Programs

  • Python
    def row(n):
        i, J, out = 0, list(range(1, n+1)), []
        while len(J) > 1:
            i = (i + 1)%len(J)
            out.append(J.pop(i))
            i = i%len(J)
            if len(J) > 1:
                out.append(J.pop(i))
        out += [J[0]]
        return out
    print([e for n in range(1, 14) for e in row(n)]) # Michael S. Branicky, Apr 28 2025

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.

Original entry on oeis.org

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, 19, 20, 27, 21, 22, 30, 23, 24, 35, 25, 26, 35, 27, 28, 38, 29, 30, 44, 31, 32, 43, 33, 34, 46, 35, 36, 54, 37, 38, 51, 39, 40, 54, 41, 42, 61, 43, 44, 59, 45, 46, 62, 47
Offset: 1

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Apr 14 2025

Keywords

Comments

This elimination process is related to the under-down-down card dealing.

Examples

			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.
		

Crossrefs

Programs

  • Python
    def a(n):
        i, J, out, c = 0, list(range(1, n+1)), [], 0
        while len(J) > 1:
            i = (i + 1)%len(J)
            q = J.pop(i)
            c += 1
            if q == 1:
                return c
            i = i%len(J)
            if len(J) > 1:
                q = J.pop(i)
                c += 1
                if q == 1:
                    return c
        return c+1
    print([a(n) for n in range(1, 71)]) # Michael S. Branicky, Apr 28 2025

Formula

a(3k+1) = 2k+1; a(3k-1) = 2k.

A382528 Triangle T(n,k) read by rows, where row n is a permutation of the numbers 1 through n, such that if a deck of n cards is prepared in this order, and under-down-down dealing is used, then the resulting cards will be dealt in increasing order.

Original entry on oeis.org

1, 2, 1, 3, 1, 2, 3, 1, 2, 4, 4, 1, 2, 5, 3, 6, 1, 2, 5, 3, 4, 5, 1, 2, 6, 3, 4, 7, 6, 1, 2, 8, 3, 4, 7, 5, 9, 1, 2, 7, 3, 4, 8, 5, 6, 7, 1, 2, 8, 3, 4, 10, 5, 6, 9, 8, 1, 2, 11, 3, 4, 9, 5, 6, 10, 7, 11, 1, 2, 9, 3, 4, 10, 5, 6, 12, 7, 8, 9, 1, 2, 10, 3, 4, 13, 5, 6, 11, 7, 8, 12
Offset: 1

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Apr 12 2025

Keywords

Comments

Under-down-down dealing is a dealing pattern where the top card is placed at the bottom of the deck, then the next two cards are dealt. This pattern repeats until all of the cards have been dealt.
This card dealing is related to a variation on the Josephus problem, where one person is skipped, and the next two are eliminated. The card in row n and column k is x if and only if in the corresponding Josephus problem with n people, the person number x is the k-th person eliminated. Equivalently, each row of Josephus triangle ??? is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is A007494(n) = ceiling(3n/2).
The first column is A381048, the order of elimination of the first person in the Josephus problem.
The index of the largest number in row n is A337191(n), corresponding to the index of the freed person in the corresponding Josephus problem.

Examples

			Consider a deck of four cards arranged in the order 3,1,2,4. Card 3 goes under, then card 1 is dealt, then card 2 is dealt, then card 4 goes under, then cards 3 and 4 are dealt. Thus, the fourth row of the triangle is 3,1,2,4.
Table begins:
1;
2, 1;
3, 1, 2;
3, 1, 2, 4;
4, 1, 2, 5, 3;
6, 1, 2, 5, 3, 4;
5, 1, 2, 6, 3, 4, 7;
6, 1, 2, 8, 3, 4, 7, 5;
		

Crossrefs

Programs

  • Python
    def T(n, A):
        return invPerm(J(n,A))
    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 DDU(n):
        return [0] + [(i)%2 for i in range(n)]
    def DUD(n):
        return DDU(n+1)[1:]
    def UDD(n):
        return DUD(n+1)[1:]
    seq = []
    for i in range(1,10):
        seq += T(i, UDD(i))
    print(", ".join([str(v) for v in seq]))
    
  • Python
    def row(n):
        i, J, out = 0, list(range(1, n+1)), []
        while len(J) > 1:
            i = (i + 1)%len(J)
            out.append(J.pop(i))
            i = i%len(J)
            if len(J) > 1:
                out.append(J.pop(i))
        out += [J[0]]
        return [out.index(j)+1 for j in list(range(1, n+1))]
    print([e for n in range(1, 14) for e in row(n)]) # Michael S. Branicky, Apr 28 2025

Formula

T(n,k) = T(n-2,k-3) + 2. T(1,1) = 1. For the first 3 columns, we have T(n,1) = T(n-2,n-2) + 2, T(n,2) = 1, and T(n,3) = 2.
It follows that T(n,3k+2) = 2k+1, T(n,3k) = 2k.

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

Original entry on oeis.org

1, 2, 3, 3, 3, 6, 6, 3, 9, 6, 3, 9, 6, 12, 9, 15, 12, 18, 15, 3, 18, 6, 21, 9, 24, 12, 27, 15, 3, 18, 6, 21, 9, 24, 12, 27, 15, 30, 18, 33, 21, 36, 24, 39, 27, 42, 30, 45, 33, 48, 36, 51, 39, 54, 42, 3, 45, 6, 48, 9, 51, 12, 54, 15, 57, 18, 60, 21, 63, 24, 66, 27
Offset: 1

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, May 12 2025

Keywords

Comments

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

Crossrefs

Programs

  • Maple
    Consider 4 people in a circle in order 1,2,3,4. In the first round, person 1 is eliminated, then person 2 is eliminated, then person 3 is skipped. Now people are in order 4,3. In the second round, person 4 is eliminated. The last person, person 3, is freed. Thus, a(4) = 3.
  • Python
    def a(n):
        i, J, out = 0, list(range(1, n+1)), []
        while len(J) > 1:
            J.pop(i)
            i = i%len(J)
            if len(J) > 1:
                J.pop(i)
            i = i%len(J)
            i = (i + 1)%len(J)
        return J[0]
    print([a(n) for n in range(1, 73)])
Showing 1-4 of 4 results.