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.

A378821 Lexicographically earliest sequence of distinct positive integers such that the count of integers between a(n) and a(n-1), excluding values already in the sequence, is distinct from the same count for any other a(k) and a(k-1) at the time they occurred.

Original entry on oeis.org

1, 2, 4, 7, 11, 3, 10, 18, 5, 16, 26, 6, 22, 35, 8, 27, 42, 9, 32, 51, 12, 37, 58, 13, 41, 66, 14, 47, 74, 15, 53, 83, 17, 57, 90, 19, 62, 98, 20, 68, 106, 21, 73, 115, 23, 78, 122, 24, 84, 131, 25, 88, 138, 28, 94, 147, 29, 99, 154, 30, 103, 162, 31, 109, 170, 33
Offset: 1

Views

Author

Neal Gersh Tolunsky, Dec 08 2024

Keywords

Examples

			 a(1-5) = 1,2,4,7,11 follow a straightforward pattern of counting up, where each pair of consecutive terms encloses (in order) 0,1,2,3 unused values.
  1,2,3,4,5,6,7,8,9,10,11
  1 2 * 4 * * 7 * * *  11
  ^ ^   ^     ^        ^
  At a(6), a(5)=11 and a(6)=3 enclose 5 unused values:
  1,2,3,4,5,6,7,8,9,10,11
  1 2 3 4 * * 7 * * *  11
      ^                ^
		

Crossrefs

Programs

  • Python
    from itertools import count, islice
    def c(k, m, a): return sum(1 for i in range(min(k, m)+1, max(k, m)) if i not in a)
    def agen(): # generator of terms
        a, d, an, m = set(), set(), 1, 2
        while True:
            yield an
            a.add(an)
            found, k = False, m
            if m < an:
                ck = c(k, an, a)
                for k in range(m, an):
                    if k not in a:
                        if ck not in d:
                            found = True
                            break
                        ck -= 1
            if not found:
                kk = max(m, an+1)
                ck = c(kk, an, a)
                for k in count(kk):
                    if k not in a:
                        if ck not in d:
                            found = True
                            break
                        ck += 1
            d.add(c(an, k, a))
            an = k
            while m in a: m += 1
    print(list(islice(agen(), 66))) # Michael S. Branicky, Dec 09 2024