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 11-20 of 35 results. Next

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

Original entry on oeis.org

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

Views

Author

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

Keywords

Comments

Under-under-under-down dealing is a dealing pattern where the top three cards are placed at the bottom of the deck, and then the next card is dealt. This pattern repeats until all of the cards have been dealt.
This card dealing can equivalently be seen as a variation on the Josephus problem where every 4th person is eliminated. T(n,k) is the number of eliminations in the Josephus problem that occur before the k-th person is eliminated. Equivalently, each row of T is the inverse permutation of the corresponding row of the Josephus triangle A384772, i.e. A384772(n,T(n,k)) = k.
The total number of moves for row n is 4n.
The first column is A384774(n), the order of elimination of the first person in the Josephus problem.
The index of the largest number in row n is A088333(n), corresponding to the index of the freed person in the corresponding Josephus problem.
T(n,4j) = j, for 4j <= n.

Examples

			Consider a deck of four cards arranged in the order 2,4,3,1. If we put the top 3 cards under and deal the next card, we will deal card number 1. Now the deck is ordered 2,4,3. If we place 3 cards under and deal the next one, we will deal card number 2, and be left with cards 4,3. Again placing 3 cards under and dealing the next, we will deal card number 3, leaving card number 4 to be dealt last. The dealt cards are in order. Thus, the fourth row of the triangle is 2,4,3,1.
The triangle begins as follows:
 1
 2, 1;
 1, 3, 2;
 2, 4, 3, 1;
 5, 4, 2, 1, 3;
 3, 2, 4, 1, 6, 5;
 2, 7, 6, 1, 4, 3, 5;
 5, 4, 6, 1, 3, 8, 7, 2;
 9, 8, 3, 1, 6, 5, 7, 2, 4
		

Crossrefs

Programs

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

Formula

T(n, 4) = 1 for n >= 4
T(n, k) = T(n-1, k-4 mod n) + 1 if k !== 4 (mod n).

A384772 Triangle read by row: T(n,k) is the number of the k-th eliminated person in a variant 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, 1, 3, 2, 4, 1, 3, 2, 4, 3, 5, 2, 1, 4, 2, 1, 3, 6, 5, 4, 1, 6, 5, 7, 3, 2, 4, 8, 5, 2, 1, 3, 7, 6, 4, 8, 3, 9, 6, 5, 7, 2, 1, 4, 8, 2, 7, 3, 10, 9, 1, 6, 5, 4, 8, 1, 6, 11, 7, 3, 2, 5, 10, 9, 4, 8, 12, 5, 10, 3, 11, 7, 6, 9, 2, 1, 4, 8, 12, 3, 9, 1, 7, 2, 11, 10, 13, 6, 5
Offset: 1

Views

Author

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

Keywords

Comments

The numbers 1 through n are arranged in a circle. A pointer starts at position 1. With each turn, the pointer skips three numbers and the next number is eliminated. The process repeats until no numbers remain. This sequence is a concatenation of the rows of the triangle T, where T(n, k) is the elimination order of the k-th number in a circle of n numbers.
This variation of the Josephus problem can equivalently be described in terms of under-under-under-down card dealing, where the cards of a deck are dealt by alternately cycling three cards from the top "under", and then dealing the next card "down". In particular, T(n,k) is the k-th card dealt in under-under-under-down dealing if the deck begins in order 1,2,3,...,n.

Examples

			Consider 4 people in a circle. Initially, people numbered 1, 2, and 3 are skipped, and person 4 is eliminated. The remaining people are now in order 1, 2, 3. Then all three are skipped and person 1 is eliminated. The remaining people are in order 2, 3. Now, we skip over 2, 3, 2 and eliminate person 3. Person 2 is eliminated last. Thus, the fourth row of the triangle is 4, 1, 3, 2.
The triangle begins as follows:
  1;
  2, 1;
  1, 3, 2;
  4, 1, 3, 2;
  4, 3, 5, 2, 1;
  4, 2, 1, 3, 6, 5;
  4, 1, 6, 5, 7, 3, 2;
  4, 8, 5, 2, 1, 3, 7, 6;
  4, 8, 3, 9, 6, 5, 7, 2, 1
		

Crossrefs

Programs

  • Python
    def row(n):
        i, J, out = 0, list(range(1, n+1)), []
        while len(J) > 0:
            i = (i + 3)%len(J)
            out.append(J.pop(i))
        return out
    print([e for n in range(1, 14) for e in row(n)])

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

Original entry on oeis.org

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

Views

Author

Tanya Khovanova and the MIT PRIMES STEP junior group, Jan 15 2025

Keywords

Comments

Under-under-down dealing is a dealing pattern where the top card is placed at the bottom of the deck, then the next card is also placed at the bottom of the deck, and then the next card is 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 two people are skipped, and the third person is 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 A381667 is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is 3n.
The first column is A381591, the order of elimination of the first person in the Josephus problem.
The index of the largest number in row n is A054995(n), corresponding to the index of the freed person in the corresponding Josephus problem.
T(n,3j) = j, for 3j <= n.

Examples

			Consider a deck of four cards arranged in the order 4,2,1,3. Card 4 goes under, card 2 goes under, and card 1 is dealt. Now the deck is ordered 3,4,2. Card 3 goes under, card 4 goes under, and card 2 is dealt. Now the leftover deck is ordered 3,4. Card 3 goes under, card 4 goes 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 4,2,1,3.
Table begins:
  1 ;
  1, 2;
  2, 3, 1;
  4, 2, 1, 3;
  2, 4, 1, 5, 3;
  6, 4, 1, 3, 5, 2;
  6, 3, 1, 7, 5, 2, 4;
  3, 5, 1, 7, 4, 2, 8, 6;
  9, 7, 1, 4, 6, 2, 8, 5, 3;
		

Crossrefs

Programs

  • Python
    def UUD(n):
        return invPerm(UUDES(n))
    def UUDES(n):
        l=[]
        for i in range(n):
            l.append(i+1)
        index = 0
        P=[]
        for i in range(n):
            index+=2
            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
    sequence = []
    for i in range(1,20):
        sequence += [str(v) for v in UUD(i)]
    print(", ".join(sequence))
    
  • Python
    def row(n):
        i, J, out = 0, list(range(1, n+1)), []
        while len(J) > 0:
            i = (i + 2)%len(J)
            out.append(J.pop(i))
        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

T(n, 3 mod n) = 1
T(n, k) = T(n-1, k-3 mod n) + 1 if k != 3 mod n, where "a mod b" denotes the representative of the a's modular equivalence class in {0, ..., b-1}.

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.

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

Original entry on oeis.org

1, 2, 2, 2, 5, 5, 2, 8, 5, 2, 8, 5, 11, 8, 14, 11, 17, 14, 2, 17, 5, 20, 8, 23, 11, 26, 14, 2, 17, 5, 20, 8, 23, 11, 26, 14, 29, 17, 32, 20, 35, 23, 38, 26, 41, 29, 44, 32, 47, 35, 50, 38, 53, 41, 2, 44, 5, 47, 8, 50, 11, 53, 14, 56, 17, 59, 20, 62, 23, 65, 26, 68
Offset: 1

Views

Author

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

Keywords

Comments

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

Examples

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

Crossrefs

Programs

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

A381114 Triangle read by rows: T(n,k) is the number of the k-th eliminated person in a variation of the Josephus elimination process for n people, where the number of people skipped is equal to the number of letters in the previous number's English name.

Original entry on oeis.org

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

Views

Author

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

Keywords

Comments

In this variation of the Josephus elimination process, people numbered 1 through n are arranged in a circle. A pointer starts at person 1. Person 1 is eliminated, then three people are skipped because the number O-N-E has three letters. Then, the next person is eliminated. Next, three people are skipped because T-W-O has three letters, and the next person is eliminated. Then, five people are skipped because T-H-R-E-E has five letters, and so on. This repeats until no people remain. This sequence represents the triangle T(n, k), the order of elimination for the person numbered k in a circle of n people.
Every entry of the first column is 1.
In rows 5 and after, the second number is 5. In rows 9 and after, the third number is 9. In rows 15 and after, the fourth number is 15. In the limit, the numbers in a row form sequence A381128(k).

Examples

			Triangle begins:
 1;
 1, 2;
 1, 3, 2;
 1, 2, 4, 3;
 1, 5, 2, 4, 3;
 1, 5, 4, 3, 6, 2;
 1, 5, 3, 6, 2, 4, 7;
 ...
For n = 4, suppose four people are arranged in a circle. The first person is eliminated, then three people are skipped because O-N-E has three letters. The leftover people are now in order 2,3,4. Then, the next person (numbered 2) is eliminated. The leftover people are now ordered 3,4. The next three people are skipped, so the person eliminated is number 4. Then, 5 people are skipped, and the next person eliminated is number 3. Thus, the fourth row of the triangle is 1,2,4,3.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def f(n): return sum(1 for c in n2w(n).replace(" and", "") if c.isalpha())
    def row(n):
        c, i, J, out = 1, 0, list(range(1, n+1)), []
        while len(J) > 1:
            q = J.pop(i)
            out.append(q)
            i = (i + f(c))%len(J)
            c = c+1
        return out + [J[0]]
    print([e for n in range(1, 14) for e in row(n)]) # Michael S. Branicky, Feb 16 2025

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

Original entry on oeis.org

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

Views

Author

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

Keywords

Comments

In Down-SpellUnder dealing, we deal the first card, then spell the positive integers starting from O-N-E, moving a card from the top of the deck underneath the deck for each letter in the English spelling of the number, followed by dealing or "putting down" the top card. So we start by dealing the first card, then putting 3 cards under because O-N-E has three letters, then we deal the next card. Then we put 3 cards under because T-W-O has three letters, then we deal a card. Then we put 5 cards under for T-H-R-E-E, and so on. This dealing sequence is highly irregular because it depends on English spelling. The dealing pattern starts: DUUUDUUUDUUUUUD, where each "U" corresponds to putting a card “under” and each "D" corresponds to dealing a card “down”.
This card dealing can be thought of as a generalized version of the Josephus problem. In this version of the Josephus problem, we start by executing the first person, then spell the positive integers in increasing order, each time skipping past 1 person for each letter and executing the next person. The card in row n and column k is x if and only if in the corresponding Josephus problem with n people, the person numbered x is the k-th person eliminated.
Equivalently, each row of the corresponding Josephus triangle A381114 is an inverse permutation of the corresponding row of this triangle. The first column contains only ones, since person number 1 always dies first in the corresponding Josephus problem. The index of the largest number in row n is A381129(n), corresponding to the index of the freed person in the corresponding Josephus problem. The number of card moves that we need to take if we start with n cards is A381128(n).

Examples

			Triangle begins:
 1;
 1, 2;
 1, 3, 2;
 1, 2, 4, 3;
 1, 3, 5, 4, 2;
 1, 6, 4, 3, 2, 5;
 1, 5, 3, 6, 2, 4, 7;
 1, 3, 4, 5, 2, 7, 6, 8;
  ...
For n = 4, suppose there are four cards arranged in the order 1,2,4,3. Card 1 is dealt, and then three cards go under the deck because O-N-E has three letters. Now, the deck is ordered 2,4,3. Card 2 is dealt, and three cards go under because T-W-O has three letters. Now, the leftover deck is ordered 3,4. Card 3 is dealt, and five cards go under because T-H-R-E-E has five letters. Then card 4 is dealt. The dealt cards are in numerical order. Thus, the fourth row of the triangle is 1, 2, 4, 3.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def f(n): return sum(1 for c in n2w(n).replace(" and", "") if c.isalpha())
    def row(n):
        c, i, J, out = 1, 0, list(range(1, n+1)), []
        while len(J) > 1:
            q = J.pop(i)
            out.append(q)
            i = (i + f(c))%len(J)
            c = c+1
        out.append(J[0])
        return [out.index(j)+1 for j in list(range(1, n+1))]
    print([e for n in range(1, 15) for e in row(n)]) # Michael S. Branicky, Feb 16 2025

A381128 The number of card moves required to deal n cards using Down-SpellUnder dealing.

Original entry on oeis.org

1, 5, 9, 15, 20, 25, 29, 35, 41, 46, 50, 57, 64, 73, 82, 90, 98, 108, 117, 126, 133, 143, 153, 165, 176, 187, 197, 209, 221, 232, 239, 249, 259, 271, 282, 293, 303, 315, 327, 338, 344, 353, 362, 373, 383, 393, 402, 413, 424, 434, 440, 449, 458, 469, 479, 489, 498, 509, 520, 530, 536, 545, 554, 565, 575, 585, 594, 605
Offset: 1

Views

Author

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

Keywords

Comments

In Down-SpellUnder dealing, after dealing the i-th card we move a card from the top of the deck to the bottom for each letter in the English spelling of i. Then we deal the next card and proceed likewise. So we start by dealing card 1, then putting 3 cards under because O-N-E has three letters. Then, we deal the next card, and put three cards under 3 because T-W-O has three letters. We then deal again, put 5 under for T-H-R-E-E, and so on. This dealing sequence is highly irregular because it depends on English spelling. The dealing pattern starts: DUUUDUUUDUUUUUD, where D means 'deal', and U means 'under'.

Examples

			The dealing pattern to deal four cards is DUUUDUUUDUUUUUD. It contains 15 letters, so a(4) = 15.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def spell(n):
        return sum(1 for c in n2w(n).replace(" and", "").replace(" ", "").replace(",", "").replace("-", ""))
    moves_so_far = 0
    l = []
    for i in range(1, 41):
        moves_so_far += 1
        l += [str(moves_so_far)]
        moves_so_far += spell(i)
    print(", ".join(l))

Formula

a(n) = A067278(n-1) + n.

A381129 A version of the Josephus problem: a(n) is the surviving integer under the spelling version of the elimination process, called Down-SpellUnder.

Original entry on oeis.org

1, 2, 2, 3, 3, 2, 7, 8, 4, 6, 4, 6, 7, 11, 10, 3, 14, 4, 17, 11, 3, 16, 7, 16, 7, 22, 2, 8, 24, 27, 7, 21, 13, 28, 30, 8, 3, 37, 12, 7, 8, 33, 7, 33, 44, 11, 32, 8, 6, 43, 2, 18, 49, 8, 32, 54, 26, 43, 44, 30, 40, 52, 26, 44, 8, 27, 60, 16, 11, 61, 70, 14, 58, 55
Offset: 1

Views

Author

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

Keywords

Comments

Arrange n people numbered 1, 2, 3, ..., n in a circle, increasing clockwise. Execute the person numbered 1, then spell the letters of O-N-E, moving one person clockwise for each letter. Once you are done, eliminate the next person. Then, spell the letters of T-W-O; in other words, skip three people and eliminate the next person. Following this, spell the letters of T-H-R-E-E; in other words, skip five people and eliminate the next person. Continue until one person remains. The number of this person is a(n).

Examples

			Consider n = 4 people. The first person eliminated is number 1. This leaves the remaining people in the order 2, 3, 4. The second person eliminated is number 2; the people left are in the order 3, 4. The next person eliminated is numbered 4, leaving only the person numbered 3. Thus, a(4) = 3.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def f(n): return sum(1 for c in n2w(n).replace(" and", "") if c.isalpha())
    def a(n):
        c, i, J = 1, 0, list(range(1, n+1))
        while len(J) > 1:
            q = J.pop(i)
            i = (i + f(c))%len(J)
            c = c+1
        return J[0]
    print([a(n) for n in range(1, 75)]) # Michael S. Branicky, Feb 16 2025

Extensions

a(22) and beyond from Michael S. Branicky, Feb 16 2025

A381591 Elimination order of the first person in a variation of the Josephus problem, where there are n people total and two people are skipped each time.

Original entry on oeis.org

1, 1, 2, 4, 2, 6, 6, 3, 9, 6, 4, 7, 11, 5, 11, 15, 6, 13, 11, 7, 12, 16, 8, 23, 18, 9, 22, 16, 10, 17, 31, 11, 27, 30, 12, 35, 21, 13, 22, 37, 14, 30, 35, 15, 32, 26, 16, 27, 35, 17, 47, 37, 18, 53, 31, 19, 32, 47, 20, 57, 56, 21, 51, 36, 22, 37, 65, 23, 49, 70
Offset: 1

Views

Author

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

Keywords

Comments

a(3k-1) = k.

Examples

			Consider n = 4 people. The first person eliminated is number 3. This leaves the remaining people in order 4, 1, 2. The second person eliminated is number 2. Thus, the remaining people in order 4, 1. The next person eliminated is number 4. On the fourth step, person number 1 is eliminated, implying that the order of elimination of the first person is 4: a(4) = 4.
		

Crossrefs

Programs

  • Python
    def UUD(n):
        return invPerm(UUDES(n))
    def UUDES(n):
        l=[]
        for i in range(n):
            l.append(i+1)
        index = 0
        P=[]
        for i in range(n):
            index+=2
            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
    sequence = []
    for i in range(1, 71):
        sequence += [str(UUD(i)[0])]
    print(", ".join(sequence))
    
  • Python
    def a(n):
        c, i, J = 1, 0, list(range(1, n+1))
        while len(J) > 0:
            i = (i + 2)%len(J)
            q = J.pop(i)
            if q == 1: return c
            c = c+1
    print([a(n) for n in range(1, 71)]) # Michael S. Branicky, Mar 24 2025
Previous Showing 11-20 of 35 results. Next