login
A209642
A014486-codes for rooted plane trees where non-leaf branching can occur only at the leftmost branch of any level, but nowhere else. Reflected from the corresponding rightward branching codes in A071162, thus not in ascending order.
5
0, 2, 10, 12, 42, 50, 52, 56, 170, 202, 210, 226, 212, 228, 232, 240, 682, 810, 842, 906, 850, 914, 930, 962, 852, 916, 932, 964, 936, 968, 976, 992, 2730, 3242, 3370, 3626, 3402, 3658, 3722, 3850, 3410, 3666, 3730, 3858, 3746, 3874, 3906, 3970, 3412, 3668, 3732, 3860, 3748, 3876, 3908, 3972, 3752, 3880, 3912, 3976, 3920, 3984, 4000, 4032
OFFSET
0,2
COMMENTS
Like with A071162, a(n) can be computed directly from the binary expansion of n. (See the Scheme function given). However, the function is not monotone. A209641 gives the same terms in ascending order.
LINKS
FORMULA
a(n) = A056539(A071162(n)) = A036044(A071162(n)). (See also the given Scheme-function).
PROG
(Scheme) (define (A209642 n) (let loop ((n n) (s 0) (i 1)) (cond ((zero? n) s) ((even? n) (loop (/ n 2) (+ (* 4 s) 1) (* i 4))) (else (loop (/ (- n 1) 2) (* 2 (+ s i)) (* i 4))))))
(Python)
def a(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
print([a(n) for n in range(101)]) # Indranil Ghosh, May 25 2017, translated from Antti Karttunen's SCHEME code
CROSSREFS
a(n) = A209641(A209861(n)).
Sequence in context: A071162 A075165 A209641 * A061855 A358524 A144145
KEYWORD
nonn,easy
AUTHOR
Antti Karttunen, Mar 11 2012
STATUS
approved