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.

Previous Showing 31-35 of 35 results.

A378682 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 the first person is eliminated, and after that, every second person is eliminated.

Original entry on oeis.org

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

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Dec 03 2024

Keywords

Comments

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 number at the pointer is eliminated, and the pointer skips the next number. This repeats until no numbers remain. This sequence represents the triangle J(n, k), where n is the number of people in the circle, and J(n, k) is the elimination order of the k-th number in the circle.

Examples

			Consider 5 people in a circle. During the first round around the circle, people numbered 1, 3, and 5 are eliminated in this order. The next person, numbered 2, is skipped, and 4 is eliminated. Person 2 is eliminated last. Thus, the fifth row of the triangle is 1, 3, 5, 4, 2.
Triangle begins;
  1;
  1, 2;
  1, 3, 2;
  1, 3, 2, 4;
  1, 3, 5, 4, 2;
  1, 3, 5, 2, 6, 4;
  1, 3, 5, 7, 4, 2, 6;
  1, 3, 5, 7, 2, 6, 4, 8;
  1, 3, 5, 7, 9, 4, 8, 6, 2;
		

Crossrefs

Formula

T(n,1) = 1 and T(n,k) = A321298(n-1,k-1) + 1, for n,k > 1.
T(n,k) = (A321298(n,k)-2 mod n) + 1. - Pontus von Brömssen, Dec 11 2024

A381622 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 down-under-under dealing is used, then the resulting cards will be dealt in increasing order.

Original entry on oeis.org

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

Views

Author

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

Keywords

Comments

Down-under-under dealing is a dealing pattern where the top card is dealt; then the next two cards are placed at the bottom of the deck. This pattern repeats until all of the cards have been dealt.
This card dealing is related to a variation on the Josephus problem, where the first person is eliminated, then two people are skipped, and then the process is repeated. 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 A381623(n) is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is 3n-2.
The first column consists of all ones: it is the order of elimination of the first person in the Josephus problem.
The index of the largest number in row n is A054995(n-1)+1, corresponding to the index of the freed person in the corresponding Josephus problem.
T(n,3j-2) = j, for 3j-2 <= n.

Examples

			Consider a deck of four cards arranged in the order 1,3,4,2. Card 1 is dealt. Then cards 3 and 4 go under, and card 2 is dealt. Now the deck is ordered 3,4. Cards 3 and 4 go under, and card 3 is dealt. Then card 4 is dealt. The dealt cards are in order. Thus, the fourth row of the triangle is 1,3,4,2.
Table begins:
1;
1, 2;
1, 2, 3;
1, 3, 4, 2;
1, 5, 3, 2, 4;
1, 3, 5, 2, 6, 4;
1, 7, 5, 2, 4, 6, 3;
1, 7, 4, 2, 8, 6, 3, 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 DUU(n):
        return [0] + [2 for i in range(n)]
    seq = []
    for i in range(1,20):
        seq += T(i, DUU(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%len(J)
            out.append(J.pop(i))
            i = (i + 2)%len(J)
        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, Mar 27 2025

Formula

For any n, we have T(n,1) = 1. T(2,2) = 2. For n > 2, T(n,2) = T(n-1,n-2) + 1 and T(n,3) = T(n-1,n-1) + 1. For n > 3 and k > 3, T(n,k) = T(n-1,k-3) + 1.

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

Original entry on oeis.org

1, 1, 2, 1, 2, 3, 1, 4, 2, 3, 1, 4, 3, 5, 2, 1, 4, 2, 6, 3, 5, 1, 4, 7, 5, 3, 6, 2, 1, 4, 7, 3, 8, 6, 2, 5, 1, 4, 7, 2, 6, 3, 9, 5, 8, 1, 4, 7, 10, 5, 9, 6, 3, 8, 2, 1, 4, 7, 10, 3, 8, 2, 9, 6, 11, 5, 1, 4, 7, 10, 2, 6, 11, 5, 12, 9, 3, 8, 1, 4, 7, 10, 13, 5, 9, 2, 8, 3, 12, 6, 11
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 down-under-under 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 eliminates the number and then skips two numbers. 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 eliminated, and persons 2 and 3 are skipped. The remaining people are now in order 4, 2, 3. Then, person 4 is eliminated, and 2 and 3 are skipped. The remaining people are in order 2, 3. Now, person 2 is eliminated. Person 3 is eliminated last. Thus, the fourth row of the triangle is 1, 4, 2, 3.
Triangle begins:
  1;
  1, 2;
  1, 2, 3,;
  1, 4, 2, 3;
  1, 4, 3, 5, 2;
  1, 4, 2, 6, 3, 5;
  1, 4, 7, 5, 3, 6, 2;
  1, 4, 7, 3, 8, 6, 2, 5;
  ...
		

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 DUU(n):
        return [0] + [2 for i in range(n)]
    seq = []
    for i in range(1,20):
        seq += J(i, DUU(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%len(J)
            out.append(J.pop(i))
            i = (i + 2)%len(J)
        return out + [J[0]]
    print([e for n in range(1, 14) for e in row(n)]) # Michael S. Branicky, Mar 27 2025

A385513 The numbers of people in the "SpellUnder-Down" variant of the Josephus problem such that the last person is freed.

Original entry on oeis.org

1, 6, 7, 105, 181, 215, 821, 1907, 3176, 23388, 55058
Offset: 1

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Jul 01 2025

Keywords

Comments

In SpellUnder-Down dealing, we spell the number of the next card, putting a card under for each letter in the number, then we deal the next card. So we start with putting 3 cards under, for O-N-E, then deal, then 3 under for T-W-O, then deal, then 5 under for T-H-R-E-E, then deal. The dealing sequence is highly irregular because it depends on English spelling. The dealing pattern starts: UUUDUUUDUUUUUD. In the corresponding Josephus problem, we skip the next person for each under dealing, and eliminate the next person for each down dealing.
This sequence can be used in magic tricks with the SpellUnder-Down dealing pattern. The deck sizes in this sequence guarantee that after the dealing, the last card dealt is the one that was initially on the bottom.
The classical Josephus problem corresponds to under-down dealing. In this case, the last person is freed when the number of people is a power of 2 minus 1.
A naive probabilistic argument predicts the probability that A380204(k) = k is 1/k and expects this sequence to be infinite and distributed roughly as A002387. - Michael S. Branicky, Jul 24 2025

Examples

			Suppose there are 5 people in a circle. We start with skipping three people for O-N-E. After three people are skipped, the person number 4 is eliminated. The leftover people are 5,1,2,3 in order. Then we skip three people for T-W-O. The person number 3 eliminated, and the leftover people are 5,1,2 in order. Then we skip 5 people for T-H-R-E-E, and person number 2 is eliminated, and the leftover people are 5,1 in order. Then we skip four people for F-O-U-R. person number 5 is eliminated. Person 1 is freed. As person 1 is not last, 5 is NOT in this sequence.
		

Crossrefs

Formula

{k | A380204(k) = k}. - Michael S. Branicky, Jul 24 2025

Extensions

a(10)-a(11) from Michael S. Branicky, Jul 24 2025

A381151 The order of the 13 cards of one suit such that after Down-SpellUnder dealing the cards are in order; a(n) is the n-th card in the deck.

Original entry on oeis.org

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

Views

Author

Tanya Khovanova, Nathan Sheffield, and the MIT PRIMES STEP junior group, Feb 15 2025

Keywords

Comments

Number 1 corresponds to ace, 11 to jack, 12 to queen, and 13 to king.
In the Down-SpellUnder deal, we first deal out a card, and then put a card from the top of the deck underneath for each letter in the name of the dealt card. So if the first card in the deck is an ace, after dealing it out we cycle 3 cards under for each letter in A-C-E, and then we deal the next card. This sequence is the unique permutation of 13 numbers such that, if the cards of one suit begin in this order, they are dealt in increasing order.

Examples

			The first card dealt is an ace, following which the jack (i.e., 11), the 4, and the 6 are placed under the deck (for A-C-E). Then, the next card is dealt, which is 2. If we continue this process, the cards are dealt in order.
		

Crossrefs

Previous Showing 31-35 of 35 results.