

A238758


Lexicographically earliest sequence of distinct positive integers such that a(n) AND n is a power of 2 for any n>0 (AND stands for the bitwise AND operator).


2



1, 2, 5, 4, 3, 10, 9, 8, 7, 6, 12, 11, 17, 18, 20, 16, 13, 14, 24, 15, 26, 25, 33, 19, 22, 21, 34, 36, 35, 37, 40, 32, 23, 27, 29, 28, 30, 41, 48, 31, 38, 49, 52, 50, 65, 66, 68, 39, 42, 44, 69, 43, 67, 74, 73, 72, 71, 70, 76, 75, 80, 81
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

1,2


COMMENTS

This is a permutation of the positive integers.
Apparently, a selfinverse permutation.
The powers of 2 (A000079) are the fixed points.


LINKS

Paul Tek, Table of n, a(n) for n = 1..10000
Paul Tek, Perl program for this sequence
Index entries for sequences that are permutations of the natural numbers


MATHEMATICA

s = {}; Do[j=1; While[ MemberQ[s, j]  (b = BitAnd[j, n]) == 0  BitAnd[b, b1] > 0, j++]; AppendTo[s, j], {n, 62}]; s (* Giovanni Resta, Mar 05 2014 *)


PROG

(Perl) See Link section.


CROSSREFS

Cf. A238757.
Sequence in context: A072029 A309734 A309668 * A065652 A235200 A267099
Adjacent sequences: A238755 A238756 A238757 * A238759 A238760 A238761


KEYWORD

nonn


AUTHOR

Paul Tek, Mar 05 2014


STATUS

approved



