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.

A380037 For n >= 1, if there exists an m < n such that a(m) = a(n), take the largest such m and set a(n+1) as 1 more than the number of positive terms between a(m+1) and a(n-1). Otherwise, a(n+1) = -1. Start with a(1) = 0.

Original entry on oeis.org

0, -1, -1, 1, -1, 2, -1, 2, 1, 3, -1, 4, -1, 2, 4, 2, 2, 1, 7, -1, 7, 1, 3, 10, -1, 5, -1, 2, 8, -1, 3, 5, 4, 14, -1, 5, 3, 5, 2, 9, -1, 6, -1, 2, 3, 6, 3, 2, 4, 13, -1, 8, 18, -1, 3, 6, 8, 4, 7, 30, -1, 7, 2, 12, -1, 4, 6, 9, 22, -1, 5, 26
Offset: 1

Views

Author

Connor Criss, Jan 10 2025

Keywords

Comments

This sequence was meant to be a version of A181391 that is more agnostic to individual natural numbers. When a new number is encountered, -1 is used as a placeholder instead of 0, and the -1 terms are not counted when determining the next term in the sequence. So, all natural numbers are in a sense treated equally.
No zeros appear beyond the first term in the sequence. By the definition of the sequence, beyond the first term, all terms must be equal to -1 or an integer of value at least 1.
a(n) < n for all n. a(1) < 1, and for n > 1 either a(n) = -1, which is less than n for all n, or there exists m < n - 1 such that a(m) = a(n - 1) and a(n) <= n - 1 - m which is less than n.

Crossrefs

Similar to the Van Eck sequence A181391.

Programs

  • PARI
    a(max_n) = {my(v = [0], r = [], n = 1); while(#v < max_n, r = select(x->x==v[n], v, 1); if(#r>1, v=concat(v, [1+sum(m=r[#r-1]+1, r[#r]-1, v[m]>0)]), v=concat(v,[-1])); n++); v} \\ Thomas Scheuerle, Jan 11 2025
  • Python
    k = [0]
    i = 0
    j = 0
    n = 0
    negatives = 0
    total_vals = 0
    MAX = 10000
    #change value of MAX to modify number of terms generated
    index = 0
    while(index < MAX):
        n = k[-1]
        i = len(k) - 2
        j = 1
        m = 0
        while(i > -1):
            if(k[i] == k[-1]):
                k.append(j)
                m = 1
                break
            if(k[i] != -1 or k[-1] == -1):
                j = j + 1
            i = i - 1
        if m == 0:
            k.append(-1)
            negatives = negatives + 1
        index = index + 1
    for x in range(MAX):
        print(str(k[x]))