cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A277238 Folding numbers (see comments for the definition).

This page as a plain text file.
%I A277238 #37 Aug 13 2022 20:49:38
%S A277238 1,2,6,10,12,22,28,38,42,52,56,78,90,108,120,142,150,170,178,204,212,
%T A277238 232,240,286,310,346,370,412,436,472,496,542,558,598,614,666,682,722,
%U A277238 738,796,812,852,868,920,936,976,992,1086,1134,1206,1254,1338,1386,1458,1506,1596,1644,1716,1764,1848,1896,1968
%N A277238 Folding numbers (see comments for the definition).
%C A277238 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.
%C A277238 Folding numbers with an even (resp. odd) number of bits form A035928 (resp. A276795). - _N. J. A. Sloane_, Nov 03 2016
%H A277238 Lars Blomberg, <a href="/A277238/b277238.txt">Table of n, a(n) for n = 1..10000</a>
%H A277238 Programming Puzzles and Code Golf Stack Exchange, <a href="http://codegolf.stackexchange.com/questions/95458/folding-numbers">Folding Numbers</a>.
%e A277238 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.
%p A277238 N:= 16: # to get all terms < 2^N
%p A277238 M[1]:= [[1]]: M[2]:= [[1,0]]:
%p A277238 for d from 3 to N by 2 do
%p A277238   M[d]:= map(L -> [op(L[1..(d-1)/2]),1,op(L[(d+1)/2..-1])], M[d-1]);
%p A277238   if d < N then
%p A277238     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])
%p A277238   fi
%p A277238 od:
%p A277238 seq(seq(add(L[-i]*2^(i-1),i=1..d),L=M[d]),d=1..N); # _Robert Israel_, Nov 09 2016
%t A277238 {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 *)
%o A277238 (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
%Y A277238 Cf. A035928, A276795.
%K A277238 nonn,base
%O A277238 1,2
%A A277238 _Taylor J. Smith_, Oct 06 2016