A359402 Numbers whose binary expansion and reversed binary expansion have the same sum of positions of 1's, where positions in a sequence are read starting with 1 from the left.
0, 1, 3, 5, 7, 9, 15, 17, 21, 27, 31, 33, 45, 51, 63, 65, 70, 73, 78, 85, 93, 99, 107, 119, 127, 129, 150, 153, 165, 189, 195, 219, 231, 255, 257, 266, 273, 282, 294, 297, 310, 313, 325, 334, 341, 350, 355, 365, 371, 381, 387, 397, 403, 413, 427, 443, 455, 471
Offset: 1
Keywords
Examples
The binary expansion of 70 is (1,0,0,0,1,1,0), with positions of 1's {1,5,6}, while the reverse positions are {2,3,7}. Both sum to 12, so 70 is in the sequence.
Crossrefs
Programs
-
Mathematica
Select[Range[0,100],#==0||Mean[Join@@Position[IntegerDigits[#,2],1]]==(IntegerLength[#,2]+1)/2&]
-
Python
from functools import reduce from itertools import count, islice def A359402_gen(startvalue=0): # generator of terms return filter(lambda n:(r:=reduce(lambda c, d:(c[0]+d[0]*(e:=int(d[1])),c[1]+e),enumerate(bin(n)[2:],start=1),(0,0)))[0]<<1==(n.bit_length()+1)*r[1],count(max(startvalue,0))) A359402_list = list(islice(A359402_gen(),30)) # Chai Wah Wu, Jan 08 2023
Comments