OFFSET
1,2
COMMENTS
A264662(n,a(n)) = A000040(n): a(n) = index of prime(n) in n-th row of triangle A264662. - Reinhard Zumkeller, Nov 20 2015
LINKS
John Bodeen, Table of n, a(n) for n = 1..24771
John Bodeen, OCaml program to generate the sequence
EXAMPLE
S_1 = [01], a(1) = 1;
S_2 = [01, 11], a(2) = 2;
S_3 = [01, 101, 11], a(3) = 2;
S_4 = [01, 101, 11, 111], a(4) = 4;
S_5 = [01, 101, 11, 1101, 111], a(5) = 4;
S_5 = [01, 101, 1011, 11, 1101, 111], a(6) = 3;
...
MAPLE
s:= proc(n) s(n):= cat("", convert(ithprime(n), base, 2)[]) end:
a:= n-> ListTools[BinarySearch](sort([seq(s(i), i=1..n)]), s(n)):
seq(a(n), n=1..100); # Alois P. Heinz, Nov 19 2015
MATHEMATICA
S[n_] := S[n] = SortBy[Prime[Range[n]], StringJoin @@ ToString /@ Reverse[IntegerDigits[#, 2]]&];
a[n_] := FirstPosition[S[n], Prime[n]][[1]];
Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Sep 22 2021 *)
PROG
(Haskell)
import Data.List (insertBy); import Data.Function (on)
import Data.List (elemIndex); import Data.Maybe (fromJust)
a263856 n = a263856_list !! (n-1)
a263856_list = f [] a004676_list where
f bps (x:xs) = y : f bps' xs where
y = fromJust (elemIndex x bps') + 1
bps' = insertBy (compare `on` (reverse . show)) x bps
-- Reinhard Zumkeller, Nov 19 2015
(Python)
from sympy import prime
def A263856(n):
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
CROSSREFS
KEYWORD
nonn,base
AUTHOR
John Bodeen, Oct 28 2015
STATUS
approved