cp's OEIS Frontend

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.

User: John Bodeen

John Bodeen's wiki page.

John Bodeen has authored 2 sequences.

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.

Original entry on oeis.org

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, 4, 31, 17, 5, 23, 12, 32, 17, 22, 32, 15, 26, 14, 42, 2, 11, 37, 29, 46, 27, 14, 9, 48, 6, 40, 2, 43, 22, 51, 18, 12, 43, 17, 39, 56, 14, 32, 45, 6, 50
Offset: 1

Author

John Bodeen, Oct 28 2015

Keywords

Comments

a(A264647(n)) = n and a(m) != n for m < A264647(n). - Reinhard Zumkeller, Nov 19 2015
A264662(n,a(n)) = A000040(n): a(n) = index of prime(n) in n-th row of triangle A264662. - Reinhard Zumkeller, Nov 20 2015

Examples

			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;
...
		

Crossrefs

A004676 is the sequence upon which the lexicographic ordering is based.
Cf. A264596.

Programs

  • 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
    
  • 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 *)
  • 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

A259356 Triangle T(n,k) read by rows: T(n,k) is the number of closed lambda-terms of size n with size 0 for the variables and k abstractions.

Original entry on oeis.org

0, 0, 1, 0, 1, 2, 0, 2, 9, 3, 0, 5, 38, 35, 4, 0, 14, 181, 284, 95, 5, 0, 42, 938, 2225, 1320, 210, 6, 0, 132, 5210, 17816, 15810, 4596, 406, 7
Offset: 0

Author

John Bodeen, Jun 24 2015

Keywords

Examples

			In table format, the first few rows:
{0},
{0,1},
{0,1,2},
{0,2,9,3},
{0,5,38,35,4},
...
For n=3,k=2 we have the number of closed lambda terms of size three with exactly two abstractions, T(3,2,0) = 9:
\x.\y.x x
\x.\y.x y
\x.\y.y x
\x.\y.y y
(\x.x) (\y.y)
\x.(\y.y) x
\x.(\y.x) x
\x.x (\y.y)
\x.x (\y.x)
		

Crossrefs

Cf. A220894 (row sums), A000108.

Formula

T(n,k) = T(n,k,0) where T(n,k,b) where n is size, k is number of abstractions, and b is number of free variables, T(0,0,b) = b, and T(n,k,b) = T(n-1,k-1,b+1) + Sum_{i=0..n-1} Sum_{j=0..k} T(i,j,b) * T(n-1-i,k-j,b).
T(n+1,1) = A000108(n).