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.

Showing 1-1 of 1 results.

A379375 a(n) is the number of coincidences between the sequence thus far and its terms rearranged in descending order.

Original entry on oeis.org

0, 1, 0, 1, 2, 1, 2, 1, 2, 2, 2, 3, 2, 3, 2, 3, 4, 5, 4, 5, 4, 5, 4, 3, 2, 2, 2, 2, 2, 2, 2, 3, 5, 5, 7, 7, 9, 9, 9, 8, 8, 7, 8, 8, 10, 9, 8, 8, 7, 6, 4, 3, 4, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 7, 7, 7, 8, 8, 9, 9
Offset: 1

Views

Author

Neal Gersh Tolunsky, Dec 21 2024

Keywords

Comments

Equivalently, this is the number of coincidences between the reverse of the sequence and its terms rearranged in ascending order.
A379250 is a variant beginning with 1.

Examples

			To find a(5), we compare the first 4 terms of the sequence with the same terms arranged in descending order:
0, 1, 0, 1
1, 1, 0, 0
   ^  ^
We find 2 coincidences, so a(5) = 2.
		

Crossrefs

Cf. A379250.

Programs

  • Maple
    A:= [0]:
    S:= [0]:
    for n from 2 to 100 do
      m:= numboccur(0,A+S);
      A:= [op(A),m];
      j:= ListTools:-BinaryPlace(S,-m);
      S:= [op(S[1..j]),-m,op(S[j+1..-1])];
    od:
    A; # Robert Israel, Dec 22 2024
  • Mathematica
    Nest[Append[#,Count[#-Reverse[Sort[#]],0]]&,{},87] (* James C. McMahon, Jan 03 2025 *)
  • Python
    from bisect import insort
    from itertools import islice
    def agen(): # generator of terms
        a, d, an = [], [], 0
        while True:
            a.append(an)
            insort(d, an, key=lambda x: -x)
            yield an
            an = sum(1 for x, y in zip(a, d) if x == y)
    print(list(islice(agen(), 87))) # Michael S. Branicky, Dec 21 2024
Showing 1-1 of 1 results.