OFFSET
1,2
COMMENTS
Folding numbers: Numbers with an even number of bits in their binary expansion such that the XOR of the left half and the reverse of the right half is the all-1's string. Numbers with an odd number of bits in their binary expansion such that the central bit is 1, and the XOR of the left (n-1)/2 bits and the reverse of the right (n-1)/2 bits is the all-1's string.
Folding numbers with an even (resp. odd) number of bits form A035928 (resp. A276795). - N. J. A. Sloane, Nov 03 2016
LINKS
Lars Blomberg, Table of n, a(n) for n = 1..10000
Programming Puzzles and Code Golf Stack Exchange, Folding Numbers.
EXAMPLE
178 in base 2 is 10110010. Taking the XOR of 1011 and 0100 (which is 0010 reversed) gives the result 1111, so 178 is in the sequence.
MAPLE
N:= 16: # to get all terms < 2^N
M[1]:= [[1]]: M[2]:= [[1, 0]]:
for d from 3 to N by 2 do
M[d]:= map(L -> [op(L[1..(d-1)/2]), 1, op(L[(d+1)/2..-1])], M[d-1]);
if d < N then
M[d+1]:= map(L -> ([op(L[1..(d-1)/2]), 0, 1, op(L[(d+1)/2..-1])], [op(L[1..(d-1)/2]), 1, 0, op(L[(d+1)/2..-1])]), M[d-1])
fi
od:
seq(seq(add(L[-i]*2^(i-1), i=1..d), L=M[d]), d=1..N); # Robert Israel, Nov 09 2016
MATHEMATICA
{1}~Join~Select[Range@ 2000, If[OddQ@ Length@ # && Take[#, {Ceiling[ Length[#]/2]}] == {0}, False, Union[Take[#, Floor[Length[#]/2]] + Reverse@ Take[#, -Floor[Length[#]/2]]] == {1}] &@ IntegerDigits[#, 2] &] (* Michael De Vlieger, Oct 07 2016 *)
PROG
(PARI) isok(n) = {if (n==1, return(1)); b = binary(n); if ((#b % 2) && (b[#b\2+1] == 0), return (0)); vecmin(vector(#b1, k, bitxor(b[k], b[#b-k+1]))) == 1; } \\ Michel Marcus, Oct 07 2016
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Taylor J. Smith, Oct 06 2016
STATUS
approved