login
Number of peaks in mountain ranges encoded by A014486, number of leaves in the corresponding rooted plane trees (the root node is never counted as a leaf).
13

%I #28 Mar 25 2021 10:21:10

%S 0,1,2,1,3,2,2,2,1,4,3,3,3,2,3,2,3,3,2,2,2,2,1,5,4,4,4,3,4,3,4,4,3,3,

%T 3,3,2,4,3,3,3,2,4,3,4,4,3,3,3,3,2,3,2,3,3,2,3,3,3,2,2,2,2,2,1,6,5,5,

%U 5,4,5,4,5,5,4,4,4,4,3,5,4,4,4,3,5,4,5,5,4,4,4,4,3,4,3,4,4,3,4,4,4,3,3,3,3

%N Number of peaks in mountain ranges encoded by A014486, number of leaves in the corresponding rooted plane trees (the root node is never counted as a leaf).

%C Sum_{i=A014137(n)..(A014137(n+1)-1)} a(i) = A001700(n), i.e., A001700(n) gives the total number of leaves in all ordered trees with n + 1 edges.

%H Indranil Ghosh, <a href="/A057514/b057514.txt">Table of n, a(n) for n = 0..3485</a>

%H Antti Karttunen, <a href="http://web.archive.org/web/20050429191204/http://ndirty.cute.fi/%7Ekarttu/matikka/Nekomorphisms/gatomorf.htm">Gatomorphisms and other excursions ...</a> (Includes Scheme program)

%H Antti Karttunen, <a href="https://github.com/karttu/IntSeq/tree/master/src/Uncleaned/Catalania">Newer version of the Scheme code collection</a>

%F a(n) = A005811(A014486(n))/2 = A000120(A003188(A014486(n)))/2.

%o (Python)

%o def a005811(n): return bin(n^(n>>1))[2:].count("1")

%o def ok(n): # This function after _Peter Luschny_

%o B=bin(n)[2:] if n!=0 else 0

%o s=0

%o for b in B:

%o s+=1 if b=="1" else -1

%o if s<0: return 0

%o return s==0

%o def A(n): return [0] + [i for i in range(1, n + 1) if ok(i)]

%o l=A(200)

%o print([a005811(l[i])//2 for i in range(len(l))]) # _Indranil Ghosh_, May 21 2017

%Y Cf. A000108, A000120, A001700, A003188, A005811, A014137, A014486, A057515.

%Y a(n)-1 gives the number of zeros in A071153(n) (for n>=1).

%K nonn

%O 0,3

%A _Antti Karttunen_, Sep 03 2000