login
a(0)=0; thereafter a(n+1) = a(n) + 1 + number of 0's in binary representation of a(n), counted with A023416.
5

%I #22 Jun 03 2018 08:00:49

%S 0,2,4,7,8,12,15,16,21,24,28,31,32,38,42,46,49,53,56,60,63,64,71,75,

%T 79,82,87,90,94,97,102,106,110,113,117,120,124,127,128,136,143,147,

%U 152,158,162,168,174,178,183,186,190,193,199,203,207,210,215,218,222

%N a(0)=0; thereafter a(n+1) = a(n) + 1 + number of 0's in binary representation of a(n), counted with A023416.

%C The difference from A233271 stems from the fact that it uses A080791 to count the 0-bits in binary expansion of n, while this sequence uses A023416, which results a slightly different start for the iteration.

%H Harvey P. Dale, <a href="/A216431/b216431.txt">Table of n, a(n) for n = 0..1000</a>

%F If n<2, a(n) = 2n, otherwise, a(n) = A233272(a(n-1)). - _Antti Karttunen_, Dec 12 2013

%t NestList[#+1+DigitCount[#,2,0]&,0,60] (* _Harvey P. Dale_, Sep 25 2013 *)

%o (Python)

%o a = 0

%o for n in range(100):

%o print a,

%o ta = a

%o c0 = (a==0)

%o while ta>0:

%o c0 += 1-(ta&1)

%o ta >>= 1

%o a += 1 + c0

%o (Scheme, with memoizing definec-macro from Antti Karttunen's IntSeq-library)

%o (definec (A216431 n) (if (< n 2) (+ n n) (A233272 (A216431 (- n 1)))))

%o ;; _Antti Karttunen_, Dec 12 2013

%Y Differs from A233271 only in that this jumps directly from 0 to 2 in the beginning.

%Y Cf. A023416, A010062, A214913, A233271, A233272.

%K nonn,base

%O 0,2

%A _Alex Ratushnyak_, Sep 08 2012

%E Name edited by _Antti Karttunen_, Dec 12 2013