A379250 a(1)=1; thereafter, a(n) is the number of coincidences between the sequence thus far and its terms rearranged in descending order.
1, 1, 2, 1, 2, 1, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 5, 6, 7, 8, 7, 8, 7, 8, 7, 8, 7, 6, 5, 4, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 6, 6, 8, 8, 10, 10, 11, 12, 12, 13, 12, 12, 11, 12, 12, 11, 12, 12, 12, 12, 12, 12, 11, 11, 10, 11, 9, 9, 7
Offset: 1
Keywords
Examples
To find a(8), we compare the first 7 terms of the sequence with the same terms arranged in descending order: 1, 1, 2, 1, 2, 1, 2 2, 2, 2, 1, 1, 1, 1 ^ ^ ^ We find three coincidences, so a(8) = 3.
Links
- Neal Gersh Tolunsky, Table of n, a(n) for n = 1..10000
- Pontus von Brömssen, Plot of n, a(n) for n = 1..100000.
Programs
-
Mathematica
Nest[Append[#,Count[#-Reverse[Sort[#]],0]]&,{1},79] (* James C. McMahon, Dec 21 2024 *)
-
Python
from bisect import insort from itertools import islice def agen(): # generator of terms a, d, an = [], [], 1 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(), 80))) # Michael S. Branicky, Dec 21 2024
Comments