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-39 of 39 results.

A386643 Elimination order of the first person in a variation of the Josephus problem in which one person is skipped, then one is eliminated, then two people are skipped and one eliminated, then three people are skipped and so on.

Original entry on oeis.org

1, 2, 3, 2, 3, 4, 5, 3, 7, 9, 5, 7, 4, 10, 6, 13, 16, 18, 5, 17, 10, 22, 22, 8, 17, 6, 21, 15, 27, 18, 16, 18, 23, 7, 12, 35, 35, 36, 28, 13, 15, 37, 8, 21, 30, 16, 37, 26, 30, 41, 23, 19, 9, 28, 33, 13, 28, 44, 50, 35, 60, 58, 53, 10, 47, 61, 41, 37, 26, 34, 70, 15, 66, 34, 50, 11, 55, 19, 70, 70
Offset: 1

Views

Author

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

Keywords

Examples

			Consider 4 people in a circle. Initially, person number 1 is skipped, and person 2 is eliminated. The remaining people are now in order 3, 4, 1. Then, two people are skipped, and person 1 is eliminated, implying that the order of elimination of the first person is 2: a(4) = 2.
		

Crossrefs

The first column of triangle A386639.

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

Original entry on oeis.org

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

Views

Author

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

Keywords

Comments

Down-under dealing is a dealing pattern where the top card is dealt then the next card is put on the bottom of the deck. Then, this pattern repeats until all cards are dealt.
This card dealing is related to a variation of the Josephus problem, where the first person is eliminated and the second person is skipped. The card in row n and column k is x if and only if in the Josephus problem variation with n people, the person number x is the k-th person eliminated. Equivalently, each row of the Josephus triangle A378682 related to this variation is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is 2n-1.
The first column is the order of elimination of the first person in the corresponding variation of the Josephus problem and consists of all ones.
The index of the largest number in row n is A152423(n), corresponding to the index of the freed person in this variation of the Josephus problem.
T(n,2j-1) = j, for 2j-1 <= n.
Sequence A378635 represents a similar triangle for under-down dealing.

Examples

			Suppose there are four cards arranged in order 1,3,2,4. Card 1 is dealt, and card 3 goes under, then card 2 is dealt, and card 4 goes under. Now, the leftover deck is ordered 3,4. Card 3 is dealt, and card 4 goes under. Now, the leftover deck is card 4, which is dealt. The dealt cards are in order. Thus, the fourth row of the triangle is 1,3,2,4.
Triangle begins:
  1;
  1, 2;
  1, 3, 2;
  1, 3, 2, 4;
  1, 5, 2, 4, 3;
  1, 4, 2, 6, 3, 5;
  1, 6, 2, 5, 3, 7, 4;
  1, 5, 2, 7, 3, 6, 4, 8;
  1, 9, 2, 6, 3, 8, 4, 7, 5;
		

Crossrefs

Programs

  • Mathematica
    row[n_] := Module[{ds, res, k, i = 1, len}, ds = CreateDataStructure["Queue", Range[n]]; res = CreateDataStructure["FixedArray", n]; While[(ds["Length"] >= 2), res["SetPart", i++, ds["Pop"]]; ds["Push", ds["Pop"]];]; res["SetPart", n, ds["Pop"]]; Flatten[PositionIndex[res["Elements"]] /@ Range[n]]]; Array[row, 14, 1] // Flatten (* Shenghui Yang, May 16 2025 *)

Formula

T(1,1) = 1, for n > 1, T(n,1) = 1 and T(n,2) = T(n-1,n-1) + 1. For n > 1 and k > 2, T(n,k) = T(n-1,k-2) + 1.
From Pontus von Brömssen, Dec 11 2024: (Start)
T(n,k) = A378635(n-1,k-1) + 1 for 2 <= k <= n.
T(n,k) = A378635(n,(k mod n) + 1).
(End)

A383076 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 elimination pattern is eliminate-skip-eliminate.

Original entry on oeis.org

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

Views

Author

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

Keywords

Comments

This Josephus problem is related to down-under-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 eliminates the first number, skips the second, then eliminates the third. 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, person number 2 is skipped, and person number 3 is eliminated. The remaining people are now in order 4, 2. Then, 4 is eliminated, and 2 is left. Thus, the fourth row of the triangle is 1, 3, 4, 2, the order of elimination.
Triangle begins;
1;
1, 2;
1, 3, 2;
1, 3, 4, 2;
1, 3, 4, 2, 5;
1, 3, 4, 6, 2, 5;
1, 3, 4, 6, 7, 5, 2;
1, 3, 4, 6, 7, 2, 5, 8;
		

Crossrefs

Programs

  • 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 + 1)%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

A383847 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-down-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, 2, 4, 3, 1, 2, 5, 3, 4, 1, 2, 5, 3, 4, 6, 1, 2, 6, 3, 4, 7, 5, 1, 2, 8, 3, 4, 7, 5, 6, 1, 2, 7, 3, 4, 8, 5, 6, 9, 1, 2, 8, 3, 4, 10, 5, 6, 9, 7, 1, 2, 11, 3, 4, 9, 5, 6, 10, 7, 8, 1, 2, 9, 3, 4, 10, 5, 6, 12, 7, 8, 11, 1, 2, 10, 3, 4, 13, 5, 6, 11, 7, 8, 12, 9
Offset: 1

Views

Author

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

Keywords

Comments

Down-down-under dealing is a dealing pattern where the top two cards are dealt, then the third card is 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 two people are eliminated, and the third person is skipped. 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 A383845 is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is A001651(n) = floor((3*n-1)/2).
The index of the largest number in row n is A383846(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 1,2,4,3. In round 1, card 1 is dealt, card 2 is dealt, and card 4 goes under. Now the deck is ordered 3,4. In round 2, card 3 is dealt, then card 4 is dealt. The dealt cards are in order. Thus, the fourth row of the triangle is 1,2,4,3.
The table begins:
  1;
  1, 2;
  1, 2, 3;
  1, 2, 4, 3;
  1, 2, 5, 3, 4;
  1, 2, 5, 3, 4, 6;
  1, 2, 6, 3, 4, 7, 5;
  1, 2, 8, 3, 4, 7, 5, 6;
		

Crossrefs

Programs

  • Python
    def row(n):
        i, J, out = 0, list(range(1, n+1)), []
        while len(J) > 1:
            out.append(J.pop(i))
            i = i%len(J)
            if len(J) > 1:
                out.append(J.pop(i))
            i = (i + 1)%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)])

Formula

T(n,3j+1) = 2j+1, for 3j+1 <= n. T(n,3j+2) = 2j+2, for 3j+2 <= n.

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-39 of 39 results.