login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Number of ways n can be written as the sum of two numbers whose binary expansions have even numbers of zeros; also number of ways n can be written as the sum of two numbers whose binary expansions have odd numbers of zeros.
1

%I #22 Dec 03 2024 12:29:42

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

%T 6,3,7,6,1,7,6,4,8,6,3,7,7,5,8,7,4,9,5,6,11,6,6,9,6,7,11,8,5,10,8,7,

%U 12,8,7,11,7,9,12,10,6,12,9,7,17,9,6,13,10,9,15,12,5,14,12,9,16,11,9,14,11

%N Number of ways n can be written as the sum of two numbers whose binary expansions have even numbers of zeros; also number of ways n can be written as the sum of two numbers whose binary expansions have odd numbers of zeros.

%C The only place where the two sequences differ is a(0) which is 1 for the odds and 0 for the evens.

%H Robert Israel, <a href="/A059451/b059451.txt">Table of n, a(n) for n = 1..10000</a>

%H IBM Ponder This, <a href="https://research.ibm.com/haifa/ponderthis/challenges/February2001.html">Feb. 2001</a>

%H Y.-G. Chen and B. Wang, <a href="https://www.impan.pl/en/publishing-house/journals-and-series/acta-arithmetica/all/110/3">On additive properties of two special sequences</a>, Acta Arith. 110 (3) (2003), 299-303.

%e a(16)=3 since 16=2+14=5+11=8+8 (in binary 10+1110=101+1011=1000+1000 where each term has an odd number of zeros) and since 16=1+15=4+12=7+9 (in binary 1+1111=100+1100=111+1001 where each term has an even number of zeros).

%p N:= 100: # for a(1)..a(N)

%p T:= select(t -> numboccur(0,convert(t,base,2))::even, {$0..N}):

%p f:= proc(n) nops(map(t -> n-t, T intersect {$0..n/2}) intersect T) end proc:

%p map(f, [$1..N]); # _Robert Israel_, Nov 28 2024

%o (Python)

%o def c(n): return (n.bit_length() - n.bit_count())&1 == 0

%o def a(n): return sum(1 for i in range(1, n//2+1) if c(i) and c(n-i))

%o print([a(n) for n in range(1, 96)]) # _Michael S. Branicky_, Dec 02 2024

%Y Cf. A059009 and A059010 for the odd and even binary zeros sequences.

%K nonn

%O 1,8

%A _Henry Bottomley_, Feb 02 2001