login
Characterized by a(n) XOR (a(n) + 1) = a(n) - n.
0

%I #14 Feb 24 2015 09:53:00

%S 2,5,4,11,6,9,8,23,10,13,12,19,14,17,16,47,18,21,20,27,22,25,24,39,26,

%T 29,28,35,30,33,32,95,34,37,36,43,38,41,40,55,42,45,44,51,46,49,48,79,

%U 50,53,52,59,54,57,56,71,58,61,60,67,62,65,64,191,66,69,68,75,70,73,72

%N Characterized by a(n) XOR (a(n) + 1) = a(n) - n.

%C a(n) is obtained by "adding 1 to the part of the binary expansion of n-1 to the left of the least significant 0". For example, to work out a(92) first write 91 in binary: 1011011. The part to the left of the least significant 0 is 1011 (eleven) and when we add 1 we get 1100 (twelve). Thus a(92) in binary is 1100011, so a(92)=99. This makes it clear that the map "n goes to a(n)" is a bijection from the positive integers to the positive integers without 1, 3, 7, 15, 31 etc.

%F a(n) = 2*A006519(n) + n - 1.

%F Recurrence: a(2n) = 2a(n)+1, a(2n+1) = 2n+2. - _Ralf Stephan_, Aug 21 2013

%t a[n_] := a[n] = If[EvenQ[n], 2*a[n/2]+1, n+1]; a[1]=2; Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Feb 24 2015, after _Ralf Stephan_ *)

%o (PARI) a(n)=2*2^valuation(n,2)+n-1; \\ _Ralf Stephan_, Aug 21 2013

%K easy,nonn

%O 1,1

%A _Paul Boddington_, Apr 09 2006