OFFSET
1,3
COMMENTS
Every positive integer occurs exactly twice in this sequence.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
FORMULA
a(1) = a(2) = 1; for i >= 2, a(2 i-1) = 2 a(i-1) and a(2 i) = 2 a(i-1) + 1. Robert Israel, Apr 03 2014
EXAMPLE
27 is the 9th (odd) palindrome when written in binary. 27 in binary is 11011. Take the leftmost half of the digits (including the middle digit), and we have 110. a(9) is decimal equivalent of this, which is 6.
MAPLE
read("transforms3") ; a006995 := BFILETOLIST("b006995.txt") ; chop := proc(L) [op(1.. floor((nops(L)+1)/2), L)] ; end: for n from 2 to 100 do p := op(n, a006995) ; bdgs := chop(convert(p, base, 2)) ; add(op(-i, bdgs)*2^(i-1), i=1..nops(bdgs)) ; printf("%d, ", %) ; end do: # R. J. Mathar, Aug 01 2009
A162751:= proc(n) option remember;
if n <= 2 then 1
elif n::odd then 2*procname((n-1)/2)
else 2*procname(n/2-1)+1
end if
end proc; # Robert Israel, Apr 03 2014
MATHEMATICA
a[n_] := a[n] = If[n <= 2, 1, If[OddQ[n], 2 a[(n-1)/2], 2 a[n/2-1] + 1]];
Array[a, 75] (* Jean-François Alcover, Apr 06 2020, after Robert Israel *)
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Leroy Quet, Jul 12 2009
EXTENSIONS
More terms from R. J. Mathar, Aug 01 2009
STATUS
approved