%I #39 Apr 25 2024 13:12:39
%S 0,1,3,2,6,4,5,7,15,11,9,13,12,8,10,14,30,22,18,26,24,16,20,28,29,21,
%T 17,25,27,19,23,31,63,47,39,55,51,35,43,59,57,41,33,49,53,37,45,61,60,
%U 44,36,52,48,32,40,56,58,42,34,50,54,38,46,62,126,94,78
%N Lexicographically earliest sequence of distinct nonnegative terms such that for any n >= 0, a(n+1) is obtained by inverting the leftmost binary digit (which is not a leading zero) in a(n) or if this is not possible by inverting the rightmost leading binary zero in a(n).
%C This sequence has similarities with A003188, where we invert the rightmost possible binary digit.
%C This sequence appears to be a permutation of the nonnegative integers.
%H Rémy Sigrist, <a href="/A340250/b340250.txt">Table of n, a(n) for n = 0..8191</a>
%H Rémy Sigrist, <a href="/A340250/a340250.gp.txt">PARI program for A340250</a>
%H Rémy Sigrist, <a href="/A340250/a340250.png">Binary plot of the sequence for n = 0..256</a>
%e The first terms, alongside their binary representation, are:
%e n a(n) bin(a(n))
%e -- ---- ---------
%e 0 0 0
%e 1 1 1
%e 2 3 11
%e 3 2 10
%e 4 6 110
%e 5 4 100
%e 6 5 101
%e 7 7 111
%e 8 15 1111
%e 9 11 1011
%e 10 9 1001
%e 11 13 1101
%e 12 12 1100
%e 13 8 1000
%e 14 10 1010
%e 15 14 1110
%o (PARI) \\ See Links section.
%Y Cf. A003188, A340251, A340253 (ternary analog), A340254 (decimal analog), A340255 (factorial base analog), A340256 (primorial base analog).
%K nonn,base
%O 0,3
%A _Rémy Sigrist_, Jan 02 2021