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.

A380247 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 number of people skipped correspond to the number of letters in the next number in English alphabet.

Original entry on oeis.org

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

Views

Author

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

Keywords

Comments

In this variation of the Josephus elimination process, the numbers 1 through n are arranged in a circle. A pointer starts at position 1. Then three people are skipped because 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 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 person in the circle.
In rows 4 and after, the first number is 4. In rows 8 and after, the second number is 8. In rows 14 and after, the third number is 14. In the limit the numbers form sequence A380202.

Examples

			Triangle begins:
  1;
  2, 1;
  1, 3, 2;
  4, 1, 3, 2;
  4, 3, 2, 5, 1;
  4, 2, 5, 1, 3, 6;
  4, 1, 2, 3, 6, 5, 7;
  ...
For n = 4 suppose four people are arranged in a circle corresponding to the fourth row of the triangle. Three people are skipped for each letter in O-N-E; then the 4th person is eliminated. This means the row starts with 4. The next three people are skipped, and the person eliminated is number 1. Thus, the next element in the row is 1. Then, 5 people are skipped, and the next person eliminated is number 3. Similarly, the last person eliminated is number 2. Thus, the fourth row of this triangle is 4, 1, 3, 2.
		

Crossrefs

Programs

  • Python
    from num2words import num2words as n2w
    def spell(n):
        return sum(1 for c in n2w(n).replace(" and", "").replace(" ", "").replace(chr(44), "").replace("-", ""))
    def inverse_permutation(p):
        inv = [0] * len(p)
        for i, x in enumerate(p):
            inv[x-1] = i +1
        return inv
    def nthRow(n):
        l = []
        for i in range(0,n):
            l.append(0)
        zp = 0
        for j in range(1,n+1):
            zc = 0
            while zc <= spell(j):
                if l[zp] == 0:
                    zc += 1
                zp += 1
                zp = zp % n
            l[zp-1] = j
        return l
    l = []
    for i in range(1,15):
        l += inverse_permutation(nthRow(i))
    print(l)
    
  • 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 = 1, 0, list(range(1, n+1))
        out = []
        while len(J) > 1:
            i = (i + f(c))%len(J)
            q = J.pop(i)
            out.append(q)
            c = c+1
        out.append(J[0])
        return out
    print([e for n in range(1, 15) for e in row(n)]) # Michael S. Branicky, Feb 15 2025