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.

A346175 a(0)=0. If a(n) is a novel term, a(n+1)=a(a(n)). If a(n) has appeared before, a(n+1)=number of prior terms equal to a(n).

Original entry on oeis.org

0, 0, 1, 0, 2, 1, 1, 2, 1, 3, 0, 3, 1, 4, 2, 2, 3, 2, 4, 1, 5, 1, 6, 1, 7, 2, 5, 1, 8, 1, 9, 3, 3, 4, 2, 6, 1, 10, 0, 4, 3, 5, 2, 7, 1, 11, 3, 6, 2, 8, 1, 12, 1, 13, 4, 4, 5, 3, 7, 2, 9, 1, 14, 2, 10, 1, 15, 2, 11, 1, 16, 3, 8, 2, 12, 1, 17, 2, 13, 1, 18, 4, 6
Offset: 0

Views

Author

Keywords

Comments

This sequence is possible only with offset i=0 or 1, and a(i)=i. This is the i=0 version; variant i=1, beginning 1,1,1,2,1,3,1,4,2,1,... has similar properties.
Let conditions 0 and 1 respectively pertain to novel a(n) and extant a(n) respectively. When a(n) is novel, condition 0 gives a(n+1)=a(a(n)), a number which by definition is already extant. If a(n) has appeared k (>1) times already then by condition 1, a(n+1)=k-1. Following novel term N, a chain of repeat terms is generated by consecutive applications of condition 1, until reaching novel term N+1, whereupon a(N+1) initiates the next run of familiar terms. A novel term begets repeats of extant terms until these in turn produce another novel term, and so on; the sequence is infinite. No consecutive novel terms can be adjacent, there is at least one extant term between them, namely a(N)=1 gives N,1,N+1. The subsequence of records is the nonnegative integers appearing in order. Every number appears once, and thereafter arises infinitely many times.
a(m)=1 is the most frequently occurring term (arising both when a(m) is novel, with a(a(m))=1, and also as a(k+1) when a(k) is the second occurrence of m). The least occurring term is a(m)=0, which arises with increasing rarity as the sequence develops; namely at m= 0, 1, 2, 3, 10, 38, 225, 3635, 257942, ...
The subsequence {a(m+1): a(m) = record; 0,1,2,3,4,...} is identical to the original, so this sequence properly contains infinitely many copies of itself.
If condition 1 is replaced by the "count-back" rule of the Van Eck sequence (A181391), the result is A025480.
The plot of this sequence looks like sailboats on a lake; see links for details.

Examples

			a(0)=0 is a novel term so a(1)=a(a(0))=a(0)=0.
a(2)=1 because 0 has occurred twice.
Now a(2) is novel so a(3)=a(a(2))=a(1)=0, and so on.
		

Crossrefs

Programs

  • Mathematica
    Block[{a, c, j, k, r, nn}, nn = 120; c[_] := 0; a[0] = r = j = 0;
    Do[If[a[n - 1] > r,
      r = a[n - 1]; k = a[a[n - 1]],
      k = c[a[n - 1]] ];
      c[a[n - 1]]++;
      Set[{a[n], j}, {k, k}], {n, nn}];
    Array[a, nn, 0] ] (* Michael De Vlieger, May 25 2025 *)
  • Python
    from itertools import islice
    from collections import Counter
    def agen(): # generator of terms
        an, c, r, alst = 0, Counter(), -1, []
        while True:
            yield an
            c[an] += 1
            alst.append(an)
            if an > r:
                an, r = alst[an], an
            else:
                an = c[an] - 1
    print(list(islice(agen(), 83))) # Michael S. Branicky, May 25 2025