A071162 Simple rewriting of binary expansion of n resulting A014486-codes for rooted binary trees with height equal to number of internal vertices. (Binary trees where at each internal vertex at least the other child is leaf).
0, 2, 10, 12, 42, 44, 52, 56, 170, 172, 180, 184, 212, 216, 232, 240, 682, 684, 692, 696, 724, 728, 744, 752, 852, 856, 872, 880, 936, 944, 976, 992, 2730, 2732, 2740, 2744, 2772, 2776, 2792, 2800, 2900, 2904, 2920, 2928, 2984, 2992, 3024, 3040, 3412, 3416
Offset: 0
Links
- Antti Karttunen, Table of n, a(n) for n = 0..65535
- OEIS Wiki, Łukasiewicz words
- Index entries for sequences related to Łukasiewicz
Crossrefs
Programs
-
Python
def a036044(n): return int(''.join('1' if i == '0' else '0' for i in bin(n)[2:][::-1]), 2) def a209642(n): s=0 i=1 while n!=0: if n%2==0: n//=2 s=4*s + 1 else: n=(n - 1)//2 s=(s + i)*2 i*=4 return s def a(n): return 0 if n==0 else a036044(a209642(n)) print([a(n) for n in range(101)]) # Indranil Ghosh, May 25 2017
-
Scheme
(define (A071162 n) (let loop ((n n) (s 0) (i 1)) (cond ((zero? n) s) ((even? n) (loop (/ n 2) (+ s i) (* i 4))) (else (loop (/ (- n 1) 2) (* 2 (+ s i)) (* i 4))))))
Comments