%I #28 Apr 12 2017 04:43:19
%S 0,2,6,10,12,14,18,24,30,34,38,42,44,48,52,54,58,62,66,78,84,90,96,
%T 102,108,114,126,130,138,146,150,158,164,166,170,172,178,180,184,186,
%U 192,198,200,204,206,212,214,218,220,226,234,238,246,254,258,282,294,306,318,324,330,342,348,354,360,372,378,384,390,396
%N Numbers that are the sum of two binary palindromes of the same (binary) length.
%C Theorem: Adding two binary palindromes of length k >= 2 in all possible ways produces 3^floor((k-1)/2) distinct sums. (There are 2^floor((k-1)/2) binary palindromes of length k - see A006995.)
%H Chai Wah Wu, <a href="/A264964/b264964.txt">Table of n, a(n) for n = 1..13122</a>
%e There are four binary palindromes of length 5, namely (written in base 10) 17, 21, 27, 31, and adding them in pairs gives nine distinct numbers: 34, 38, 42, 44, 48, 52, 54, 58, 62.
%e There are eight binary palindromes of length 7, namely (written in base 10) 65, 73, 85, 93, 99, 107, 119, 127, and adding them in pairs gives 27 distinct numbers: 130, 138, 146, 150, 158, 164, 166, 170, 172, 178, 180, 184, 186, 192, 198, 200, 204, 206, 212, 214, 218, 220, 226, 234, 238, 246, 254.
%t f[n_] := Select[Map[FromDigits /@ IntegerDigits[#, 2] &, Map[Function[k, {k, # - k}], Range@ Floor[#/2]] &@ n], AllTrue[#, Reverse@ # == # &@ IntegerDigits@ # &] && IntegerLength@ First@ # == IntegerLength@ Last@ # &]; Prepend[Select[Range@ 400, Length@ f@ # > 0 &], 0] (* _Michael De Vlieger_, Nov 29 2015, Mma version 10 *)
%t Join[{0},Table[Total/@Tuples[FromDigits[#,2]&/@Select[Tuples[{1,0},n], #[[1]] != 0&&#==Reverse[#]&],2]//Union,{n,8}]//Flatten] (* _Harvey P. Dale_, Apr 12 2017 *)
%Y Cf. A006995, A261679, A241491, A261678.
%K nonn,base
%O 1,2
%A _N. J. A. Sloane_, Nov 29 2015
|