OFFSET
1,1
COMMENTS
Numbers n such that A036044(n) = n.
Also: numbers such that n+BR(n) is in A000225={2^k-1} (with BR = binary reversed). - M. F. Hasler, Dec 17 2007
Also called "antipalindromes". - Jeffrey Shallit, Feb 04 2022
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 1..10000
James Haoyu Bai, Joseph Meleshko, Samin Riasat, and Jeffrey Shallit, Quotients of Palindromic and Antipalindromic Numbers, arXiv:2202.13694 [math.NT], 2022.
Aayush Rajasekaran, Jeffrey Shallit, and Tim Smith, Sums of Palindromes: an Approach via Nested-Word Automata, preprint arXiv:1706.10206 [cs.FL], June 30 2017.
FORMULA
If offset were 0, a(2n+1) - a(2n) = 2^floor(log_2(n)+1).
EXAMPLE
38 is such a number because 38=100110; complement to get 011001, then reverse bit order to get 100110.
MAPLE
[seq(ReflectBinSeq(j, (floor_log_2(j)+1)), j=1..256)];
ReflectBinSeq := (x, n) -> (((2^n)*x)+binrevcompl(x));
binrevcompl := proc(nn) local n, z; n := nn; z := 0; while(n <> 0) do z := 2*z + ((n+1) mod 2); n := floor(n/2); od; RETURN(z); end;
floor_log_2 := proc(n) local nn, i: nn := n; for i from -1 to n do if(0 = nn) then RETURN(i); fi: nn := floor(nn/2); od: end; # Computes essentially the same as floor(log[2](n))
# alternative Maple program:
q:= n-> (l-> is(n=add((1-l[-i])*2^(i-1), i=1..nops(l))))(Bits[Split](n)):
select(q, [$1..3333])[]; # Alois P. Heinz, Feb 10 2021
MATHEMATICA
bcrQ[n_]:=Module[{idn2=IntegerDigits[n, 2]}, Reverse[idn2/.{1->0, 0->1}] == idn2]; Select[Range[3200], bcrQ] (* Harvey P. Dale, May 24 2012 *)
PROG
(PARI) for(n=1, 1000, l=length(binary(n)); b=binary(n); if(sum(i=1, l, abs(component(b, i)-component(b, l+1-i)))==l, print1(n, ", ")))
(PARI) for(i=1, 999, if(Set(vecextract(t=binary(i), "-1..1")+t)==[1], print1(i", "))) \\ M. F. Hasler, Dec 17 2007
(PARI) a(n) = my (b=binary(n)); (n+1)*2^#b-fromdigits(Vecrev(b), 2)-1 \\ Rémy Sigrist, Mar 15 2021
(Haskell)
a035928 n = a035928_list !! (n-1)
a035928_list = filter (\x -> a036044 x == x) [0, 2..]
-- Reinhard Zumkeller, Sep 16 2011
(Python)
def comp(s): z, o = ord('0'), ord('1'); return s.translate({z:o, o:z})
def BCR(n): return int(comp(bin(n)[2:])[::-1], 2)
def aupto(limit): return [m for m in range(limit+1) if BCR(m) == m]
print(aupto(3244)) # Michael S. Branicky, Feb 10 2021
(Python)
from itertools import count, islice
def A035928_gen(startvalue=1): # generator of terms >= startvalue
return filter(lambda n:n==int(format(~n&(1<<(m:=n.bit_length()))-1, '0'+str(m)+'b')[::-1], 2), count(max(startvalue, 1)))
CROSSREFS
KEYWORD
nonn,nice,easy,base
AUTHOR
EXTENSIONS
More terms from Erich Friedman
STATUS
approved