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.

A363654 Lexicographically earliest sequence of positive integers such that the n-th pair of identical terms encloses exactly a(n) terms.

Original entry on oeis.org

1, 2, 1, 3, 2, 3, 1, 2, 4, 3, 4, 5, 3, 6, 7, 4, 3, 8, 6, 9, 7, 8, 4, 10, 3, 7, 4, 6, 8, 9, 11, 10, 12, 3, 9, 13, 7, 3, 11, 9, 14, 15, 13, 16, 17, 7, 18, 3, 19, 20, 11, 14, 9, 20, 17, 15, 19, 20, 18, 21, 11, 22, 3, 23, 24, 25, 26, 14, 17, 9, 27, 28, 29, 15, 26, 19
Offset: 1

Views

Author

Eric Angelini and Gavin Lupo, Jun 13 2023

Keywords

Comments

Pairs are numbered according to the position of the second term.

Examples

			a(1) = 1. The 1st constructed pair encloses 1 term:  [1, 2, 1].
a(2) = 2. The 2nd constructed pair encloses 2 terms: [2, 1, 3, 2].
a(3) = 1. The 3rd constructed pair encloses 1 term:  [3, 2, 3].
a(4) = 3. The 4th constructed pair encloses 3 terms: [1, 3, 2, 3, 1].
a(5) = 2. The 5th constructed pair encloses 2 terms: [2, 3, 1, 2].
a(6) = 3. The 6th constructed pair encloses 3 terms: [3, 1, 2, 4, 3].
a(7) = 1. The 7th constructed pair encloses 1 term:  [4, 3, 4].
...
		

Crossrefs

Programs

  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        a, indexes = [1], {1: 0}
        yield a[-1]
        for i in count(0):
            num = 1
            while True:
                if num in indexes:
                    if (len(a) - indexes[num]) == (a[i]+1):
                        an = num; indexes[an] = len(a); a.append(an); yield an
                        break
                    else:
                        num += 1
                else:
                    an = max(a)+1; indexes[an] = len(a); a.append(an); yield an
                    num = 1
    print(list(islice(agen(), 100))) # Gavin Lupo and Michael S. Branicky, Jun 13 2023