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 A263856 #57 Sep 22 2021 05:57:52 %S A263856 1,2,2,4,4,3,2,6,9,5,11,4,3,11,14,6,13,9,11,17,3,20,14,5,2,9,23,20,12, %T A263856 4,31,17,5,23,12,32,17,22,32,15,26,14,42,2,11,37,29,46,27,14,9,48,6, %U A263856 40,2,43,22,51,18,12,43,17,39,56,14,32,45,6,50 %N A263856 Let S_n be the list of the first n primes written in binary, with least significant bits on the left, and sorted into lexicographic order; a(n) = position of n-th prime in S_n. %C A263856 a(A264647(n)) = n and a(m) != n for m < A264647(n). - _Reinhard Zumkeller_, Nov 19 2015 %C A263856 A264662(n,a(n)) = A000040(n): a(n) = index of prime(n) in n-th row of triangle A264662. - _Reinhard Zumkeller_, Nov 20 2015 %H A263856 John Bodeen, <a href="/A263856/b263856.txt">Table of n, a(n) for n = 1..24771</a> %H A263856 John Bodeen, <a href="https://github.com/jbodeen/ava/blob/master/camlib/primes.ml">OCaml program to generate the sequence</a> %e A263856 S_1 = [01], a(1) = 1; %e A263856 S_2 = [01, 11], a(2) = 2; %e A263856 S_3 = [01, 101, 11], a(3) = 2; %e A263856 S_4 = [01, 101, 11, 111], a(4) = 4; %e A263856 S_5 = [01, 101, 11, 1101, 111], a(5) = 4; %e A263856 S_5 = [01, 101, 1011, 11, 1101, 111], a(6) = 3; %e A263856 ... %p A263856 s:= proc(n) s(n):= cat("", convert(ithprime(n), base, 2)[]) end: %p A263856 a:= n-> ListTools[BinarySearch](sort([seq(s(i), i=1..n)]), s(n)): %p A263856 seq(a(n), n=1..100); # _Alois P. Heinz_, Nov 19 2015 %t A263856 S[n_] := S[n] = SortBy[Prime[Range[n]], StringJoin @@ ToString /@ Reverse[IntegerDigits[#, 2]]&]; %t A263856 a[n_] := FirstPosition[S[n], Prime[n]][[1]]; %t A263856 Table[a[n], {n, 1, 100}] (* _Jean-François Alcover_, Sep 22 2021 *) %o A263856 (Haskell) %o A263856 import Data.List (insertBy); import Data.Function (on) %o A263856 import Data.List (elemIndex); import Data.Maybe (fromJust) %o A263856 a263856 n = a263856_list !! (n-1) %o A263856 a263856_list = f [] a004676_list where %o A263856 f bps (x:xs) = y : f bps' xs where %o A263856 y = fromJust (elemIndex x bps') + 1 %o A263856 bps' = insertBy (compare `on` (reverse . show)) x bps %o A263856 -- _Reinhard Zumkeller_, Nov 19 2015 %o A263856 (Python) %o A263856 from sympy import prime %o A263856 def A263856(n): %o A263856 return 1+sorted(format(prime(i),'b')[::-1] for i in range(1,n+1)).index(format(prime(n),'b')[::-1]) # _Chai Wah Wu_, Nov 22 2015 %Y A263856 A004676 is the sequence upon which the lexicographic ordering is based. %Y A263856 Cf. A264596. %Y A263856 Cf. A264647, A264662. %K A263856 nonn,base %O A263856 1,2 %A A263856 _John Bodeen_, Oct 28 2015