A379375 a(n) is the number of coincidences between the sequence thus far and its terms rearranged in descending order.
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
Keywords
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.
Links
- Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
- Neal Gersh Tolunsky, Graph of 100000 terms
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
Comments