login
a(n) = A002487(n-1) AND A002487(n), where AND is bitwise-and (A004198).
7

%I #17 May 05 2023 12:34:30

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

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

%U 4,8,9,4,4,11,2,2,1,0,8,1,2,10,3,0,0,5,0,0,1,0,0,3,0,0,9,2,2,9,0,0,3,0,0,1,0,0,5,0,0,3,10,2,1,8,0,1,2,2,11,4

%N a(n) = A002487(n-1) AND A002487(n), where AND is bitwise-and (A004198).

%H Antti Karttunen, <a href="/A283988/b283988.txt">Table of n, a(n) for n = 1..16384</a>

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

%F a(n) = A002487(n-1) AND A002487(n), where AND is bitwise-and (A004198).

%F a(n) = A283986(n) - A283987(n).

%F a(n) = A007306(n) - A283986(n) = (A007306(n) - A283987(n))/2.

%F a(n) = A283978((2*n)-1).

%t a[0] = 0; a[1] = 1; a[n_] := If[EvenQ@ n, a[n/2], a[(n - 1)/2] + a[(n + 1)/2]]; Table[BitAnd[a[n - 1], a@ n], {n, 120}] (* _Michael De Vlieger_, Mar 22 2017 *)

%o (Scheme) (define (A283988 n) (A004198bi (A002487 (- n 1)) (A002487 n))) ;; Where A004198bi implements bitwise-AND (A004198).

%o (PARI) A(n) = if(n<2, n, if(n%2, A(n\2) + A((n + 1)/2), A(n/2)));

%o for(n=1, 120, print1(bitand(A(n - 1), A(n)),", ")) \\ _Indranil Ghosh_, Mar 23 2017

%o (Python)

%o from functools import reduce

%o def A283988(n): return sum(reduce(lambda x,y:(x[0],x[0]+x[1]) if int(y) else (x[0]+x[1],x[1]),bin(n)[-1:2:-1],(1,0)))&sum(reduce(lambda x,y:(x[0],x[0]+x[1]) if int(y) else (x[0]+x[1],x[1]),bin(n-1)[-1:2:-1],(1,0))) if n>1 else 0 # _Chai Wah Wu_, May 05 2023

%Y Odd bisection of A283978.

%Y Cf. A002487, A004198, A007306, A283986, A283987.

%Y Cf. A283973 (positions of zeros), A283974 (nonzeros).

%K nonn,base

%O 1,6

%A _Antti Karttunen_, Mar 21 2017