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.

A380317 The lexicographically earliest sequence of positive numbers which is identical to the run lengths of its first differences.

Original entry on oeis.org

1, 1, 2, 2, 2, 3, 4, 3, 2, 2, 2, 2, 3, 4, 5, 6, 5, 4, 3, 3, 3, 2, 1, 1, 1, 2, 3, 3, 3, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 3, 3, 3, 4, 5, 6, 5, 4, 3, 3, 3, 1, 1, 2, 2, 2, 3, 4, 5, 4, 3, 2, 2, 2, 2, 3, 4, 5, 4, 3, 2, 1, 1
Offset: 1

Views

Author

Dominic McCarty, Feb 13 2025

Keywords

Comments

34 is the smallest value that does not appear in the first 10000 terms.
Conjecture: Every positive integer eventually appears.
Shortly after submitting this sequence the author, Dominic McCarty, discovered that it is almost identical to A281579: in fact, a(n) = A281579(n) - 1 for all n. However, since A281579 has seniority and the present sequence has a simpler definition and is more likely to be searched for, it has been decided to retain both entries. - N. J. A. Sloane, Feb 17 2025
The index of n in the present sequence is given by A281900(n+1).

Examples

			The sequence of first differences (where the n-th term is a(n+1)-a(n)) is:
0, 1, 0, 0, 1, 1, -1, -1, 0, 0, 0, 1, 1, 1, 1, -1, -1, -1, 0, 0, ...
The run lengths of consecutive values are:
1, 1, 2, 2, 2, 3, 4, 3, 2, ...
Which is the original sequence.
		

Crossrefs

Programs

  • Python
    from itertools import groupby
    def runs(l): return [len(list(group)) for i, group in groupby(l)]
    def firstDifs(l): return [l[i]-l[i-1] for i in range(1,len(l))]
    a = [1,1]
    while len(runs(firstDifs(a))) <= 100:
        a.append(1)
        b, m = runs(firstDifs(a)), max(firstDifs(a))
        while not (all(b[n] == a[n] for n in range(len(b)-1)) and b[-1] <= a[len(b)-1]):
            a[-1] += 1
            if a[-1] > m+a[-2]+1: a.pop(); a[-1] += 1 #Backtracking needed
            b = runs(firstDifs(a))
    print(a[:len(runs(firstDifs(a)))])