This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A188215 #25 May 19 2021 16:04:23 %S A188215 0,1,2,3,3,4,6,7,4,5,7,8,11,12,14,15,5,6,8,9,12,13,15,16,20,21,23,24, %T A188215 27,28,30,31,6,7,9,10,13,14,16,17,21,22,24,25,28,29,31,32,37,38,40,41, %U A188215 44,45,47,48,52,53,55 %N A188215 Starting with an empty list, n is inserted after the a(n)th element such that the binary representations of the list's elements are always sorted lexicographically. %C A188215 The last occurrence of any positive n in this sequence is a(2^(n - 1)). %C A188215 As the list in question expands, its initial terms converge toward A131577. %C A188215 The last item of the list is always zero or an element of A075427. %H A188215 T. D. Noe, <a href="/A188215/b188215.txt">Table of n, a(n) for n = 0..1023</a> %F A188215 a(2^n + b) = n + b + 1 for b = 0 or 1. %F A188215 a(2^n - b) = 2^n - b for b = 1 or 2. %e A188215 For example, an a(n) of 3 means that n should be inserted after the 3rd element of the list to keep the elements lexicographically ordered. %e A188215 [] (Initial empty list) %e A188215 [0] (Zero inserted at the beginning: a(0) = 0) %e A188215 [0, 1] (One inserted after element 1: a(1) = 1) %e A188215 [0, 1, 10] (Two inserted after element 2: a(2) = 2) %e A188215 [0, 1, 10, 11] (Three inserted after element 3: a(3) = 3) %e A188215 [0, 1, 10, 100, 11] (Four inserted after element 3: a(4) = 3) %t A188215 lst = {}; Table[s = IntegerString[n, 2]; lst = Sort[Append[lst, s]]; Position[lst, s][[1, 1]] - 1, {n, 0, 63}] (* _T. D. Noe_, Apr 19 2011 *) %o A188215 (Python) %o A188215 l = [] %o A188215 for i in range(17): %o A188215 b = bin(i)[2:] %o A188215 l.append(b) %o A188215 l.sort() %o A188215 print(l.index(b)) %Y A188215 Cf. A264596. %K A188215 nonn,base %O A188215 0,3 %A A188215 _Grant Garcia_, Mar 24 2011 %E A188215 Program added by _Grant Garcia_, Mar 30 2011 %E A188215 Edited by _Grant Garcia_, Apr 13 2011