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

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

Views

Author

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

Keywords

Comments

Down-under-down dealing is a dealing pattern where the top card is dealt, the second card is placed at the bottom of the deck, then the third 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 the first person is eliminated, the second person is 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 A383076 is an inverse permutation of the corresponding row of this triangle.
The total number of moves for row n is A032766(n) = floor(3n/2).
The index of the largest number in row n is A381051(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,4,2,3. In round 1, card 1 is dealt, card 4 goes under, card 2 is dealt. Now the deck is ordered 3,4. In round 2, card 3 is dealt, card 4 goes under, then card 4 is dealt. The dealt cards are in order. Thus, the fourth row of the triangle is 1,4,2,3.
Table begins:
  1;
  1, 2;
  1, 3, 2;
  1, 4, 2, 3;
  1, 4, 2, 3, 5;
  1, 5, 2, 3, 6, 4;
  1, 7, 2, 3, 6, 4, 5;
  1, 6, 2, 3, 7, 4, 5, 8;
		

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"]];If[ds["Length"]>1,res["SetPart",i++,ds["Pop"]];]];res["SetPart",n,ds["Pop"]];Flatten[PositionIndex[res["Elements"]]/@Range[n]]];
    Array[row, 13, 1] // Flatten (* Shenghui Yang, May 11 2025 *)
  • 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)
            #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,3j) = 2j, for 3j <= n. T(n,3j+1) = 2j+1, for 3j+1 <= n.

A384774 Elimination order of the first person in a variation 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, 2, 5, 3, 2, 5, 9, 8, 3, 12, 6, 10, 4, 16, 12, 16, 5, 9, 20, 10, 6, 22, 21, 23, 7, 27, 13, 21, 8, 30, 23, 20, 9, 16, 31, 17, 10, 31, 24, 35, 11, 34, 20, 27, 12, 28, 34, 49, 13, 23, 31, 24, 14, 49, 55, 34, 15, 35, 27, 59, 16, 44, 38, 60, 17, 30, 53, 31
Offset: 1

Views

Author

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

Keywords

Comments

a(4k-1) = k
a(n) = A384770(n,1).

Examples

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

Crossrefs

Cf. First column of A384770.

Programs

  • Maple
    A384774 := proc(n::integer)
        local plist,eli,skip,ptr ;
        plist := [seq(i,i=1..n)] ;
        eli :=1 ;
        skip := 3;
        ptr := 0 ;
        while true do
            ptr := modp(ptr+skip,nops(plist)) ;
            if op(ptr+1,plist) = 1 then
                return eli ;
            end if;
            plist := subsop(ptr+1=NULL,plist) ;
            eli := eli+1 ;
        end do:
    end proc:
    seq(A384774(n),n=1..100) ; # R. J. Mathar, Jul 30 2025
  • Python
    def a(n):
        c, i, J = 1, 0, list(range(1, n+1))
        while len(J) > 0:
            i = (i + 3)%len(J)
            q = J.pop(i)
            if q == 1: return c
            c = c+1
    print([a(n) for n in range(1, 71)])

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

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)])

A200782 Expansion of 1 / (1 - 6*x + 20*x^3 - 15*x^4 + x^6).

Original entry on oeis.org

1, 6, 36, 196, 1071, 5796, 31395, 169884, 919413, 4975322, 26924106, 145698840, 788446400, 4266656226, 23088902733, 124944995676, 676136621430, 3658895818470, 19800020091895, 107147296401684, 579824822459421, 3137707025200000
Offset: 0

Views

Author

R. H. Hardin, Nov 22 2011

Keywords

Comments

a(n) is the number of words of length n over an alphabet of size 6 which do not contain any strictly decreasing factor (consecutive subword) of length 3.
Equivalently, dimensions of homogeneous components of the universal associative envelope for a certain nonassociative triple system [Bremner].
This is the g.f. corresponding to row 6 of A225682.

Examples

			a(n) is also the number of words of length n over an alphabet of size 6 which do not contain any strictly increasing factor of length 3. Some solutions for n=5:
..5....5....0....3....2....4....3....3....3....3....0....3....3....1....0....1
..1....5....0....0....4....5....1....1....3....5....1....0....2....0....3....4
..3....5....1....0....4....3....1....4....5....0....1....5....1....0....0....3
..0....0....0....4....1....1....1....4....2....4....1....1....2....5....4....1
..1....4....2....0....0....0....1....3....1....4....3....2....2....2....4....5
		

Crossrefs

Column 5 of A200785.
G.f. corresponds to row 6 of A225682.

Programs

  • Mathematica
    CoefficientList[Series[1 / (1 - 6*x + 20*x^3 - 15*x^4 + x^6), {x, 0, 20}], x] (* Vaclav Kotesovec, Jan 26 2015 *)
    LinearRecurrence[{6,0,-20,15,0,-1},{1,6,36,196,1071,5796},30] (* Harvey P. Dale, Jul 28 2019 *)
  • PARI
    Vec(1/(1-6*x+20*x^3-15*x^4+x^6) + O(x^30)) \\ Michel Marcus, Jan 26 2015

Formula

G.f.: 1 / (1 - 6*x + 20*x^3 - 15*x^4 + x^6).
a(n) = 6*a(n-1) - 20*a(n-3) + 15*a(n-4) - a(n-6).

Extensions

Entry revised by N. J. A. Sloane, May 17 2013, merging this with A225381
Typo in name corrected by Michel Marcus, Jan 26 2015

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
Previous Showing 11-20 of 39 results. Next