login
a(n) = 1 if there are no odd runs of 1's in the binary expansion of n followed by a 0 to their right, 0 otherwise.
6

%I #14 Dec 02 2017 21:56:28

%S 1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1,0,0,

%T 0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,0,0,

%U 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,1,0,0,0,0,1,1,0,1,0,0,0,0,0,0,0,0,1

%N a(n) = 1 if there are no odd runs of 1's in the binary expansion of n followed by a 0 to their right, 0 otherwise.

%H Antti Karttunen, <a href="/A295896/b295896.txt">Table of n, a(n) for n = 0..65537</a>

%H <a href="/index/Bi#binary">Index entries for sequences related to binary expansion of n</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%F a(0) = 1; and then after, for odd n, a(n) = a((n-1)/2), for even n, a(n) = 0 if A007814(1+(n/2)) is odd, otherwise a(n/2).

%F a(n) = A053866(A005940(1+n)) = A000035(A000203(A005940(1+n))).

%F a(n) = A295875(n) + A295895(n) mod 2.

%e Drawing the terms as a binary tree (the first six levels shown) helps in seeing where terms of A028982 (squares and twice squares) are located in Doudna-tree (A005940, at the positions where 1's occur here):

%e 1

%e |

%e 1

%e ............../ \..............

%e 0 1

%e ....../ \...... ....../ \......

%e 0 0 1 1

%e / \ / \ / \ / \

%e / \ / \ / \ / \

%e 0 0 0 0 1 1 0 1

%e / \ / \ / \ / \ / \ / \ / \ / \

%e 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 1

%t Array[Boole@ NoneTrue[Partition[PadRight[#, # + Boole[OddQ@ #] &@ Length@ #, ""] /. _?StringQ -> {0, 0}, 2, 2][[All, All, -1]] &@ Map[{First@ #, Length@ #} &, Split@ IntegerDigits[#, 2]], And[OddQ@ #1, #2 > 0] & @@ # &] &, 120, 0] (* _Michael De Vlieger_, Dec 02 2017 *)

%o (Scheme, with memoization-macro definec)

%o (definec (A295896 n) (cond ((zero? n) 1) ((odd? n) (A295896 (/ (- n 1) 2))) ((odd? (A007814 (+ 1 (/ n 2)))) 0) (else (A295896 (/ n 2)))))

%Y Cf. A005940, A007814, A037011, A053866, A295875, A295895.

%Y Characteristic function of A295897.

%K nonn,base

%O 0

%A _Antti Karttunen_, Dec 01 2017