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.

Showing 1-4 of 4 results.

A236854 Self-inverse permutation of natural numbers: a(1)=1, then a(p_n)=c_{a(n)}, a(c_n)=p_{a(n)}, where p_n = n-th prime, c_n = n-th composite.

Original entry on oeis.org

1, 4, 9, 2, 16, 7, 6, 23, 3, 53, 26, 17, 14, 13, 83, 5, 12, 241, 35, 101, 59, 43, 8, 41, 431, 11, 37, 1523, 75, 149, 39, 547, 277, 191, 19, 179, 27, 3001, 31, 157, 24, 12763, 22, 379, 859, 167, 114, 3943, 1787, 1153, 67, 1063, 10, 103, 27457, 127, 919, 89, 21
Offset: 1

Views

Author

Antti Karttunen, Feb 01 2014, based on Katarzyna Matylla's original but misplaced definition for A135044 from Feb 11 2008

Keywords

Comments

Shares with A026239 the property that the prime-positions 2, 3, 5, 7, ... contain only composite values and the composite-positions 4, 6, 8, 9, ..., etc. contain only prime values. However, instead of placing terms in those subsets in monotone order this sequence recursively permutes the order of both subsets with the emerging permutation itself, so this is a kind of "deep" variant of A026239. Alternatively, this can be viewed as yet another "entanglement permutation", where two pairs of complementary subsets of natural numbers are entangled with each other. In this case a complementary pair primes/composites (A000040/A002808) is entangled with a complementary pair composites/primes.
Maps A006508 to A007097 and vice versa.

Examples

			a(5)=c(a(3))=c(9)=16, because 5=prime(3), and the 9th composite number is c(9)=16.
Thus a(10)=prime(a(5))=prime(16)=53 (since 10 is the 5th composite), a(18)=prime(a(10))=prime(53)=241 (since 18 is the 10th composite), a(28)=prime(a(18))=prime(241)=1523.
A significant record value is a(198) = prime(a(152)) = prime(563167303) since 198=c(152); a(152)=prime(a(115)) since 152=c(115); a(115)=prime(a(84)); a(84)=prime(a(60)); a(60)=prime(a(42)); a(42)=prime(a(28)).
		

Crossrefs

Differs from A135044 for the first time at n=8, where A135044(8)=13, while here a(8)=23.

Programs

  • Mathematica
    terms = 150; cc = Select[Range[4, 2 terms^2(*empirical*)], CompositeQ]; compositePi[k_?CompositeQ] := FirstPosition[cc, k][[1]]; a[1] = 1; a[p_?PrimeQ] := a[p] = cc[[a[PrimePi[p]]]]; a[k_] := a[k] = Prime[a[ compositePi[k]]]; Array[a, terms] (* Jean-François Alcover, Mar 02 2016 *)
  • PARI
    A236854(n)={if(isprime(n), A002808(A236854(primepi(n))), n==1&&return(1);prime(A236854(n-primepi(n)-1)))} \\ without memoization: not much slower. - M. F. Hasler, Feb 03 2014
    
  • PARI
    a236854=vector(999);a236854[1]=1;A236854(n)={a236854[n]&&return(a236854[n]); a236854[n]=if(isprime(n), A002808(A236854(primepi(n))), prime(A236854(n-primepi(n)-1)))} \\ Version with memoization. - M. F. Hasler, Feb 03 2014
    
  • Python
    from sympy import primepi, prime, isprime
    def a002808(n):
        m, k = n, primepi(n) + 1 + n
        while m != k: m, k = k, primepi(k) + 1 + n
        return m # this function from Chai Wah Wu
    def a(n): return n if n<2 else a002808(a(primepi(n))) if isprime(n) else prime(a(n - primepi(n) - 1))
    print([a(n) for n in range(1, 101)]) # Indranil Ghosh, Jun 07 2017

Formula

a(1)=1, a(p_i) = A002808(a(i)) for primes with index i, a(c_j) = A000040(a(j)) for composites with index j (where 4 has index 1, 6 has index 2, and so on).

Extensions

Values double-checked by M. F. Hasler, Feb 03 2014

A236542 Array T(n,k) read along descending antidiagonals: row n contains the primes with n steps in the prime index chain.

Original entry on oeis.org

2, 7, 3, 13, 17, 5, 19, 41, 59, 11, 23, 67, 179, 277, 31, 29, 83, 331, 1063, 1787, 127, 37, 109, 431, 2221, 8527, 15299, 709, 43, 157, 599, 3001, 19577, 87803, 167449, 5381, 47, 191, 919, 4397, 27457, 219613, 1128889, 2269733, 52711
Offset: 1

Views

Author

R. J. Mathar, Jan 28 2014

Keywords

Comments

Row n contains the primes A000040(j) for which A049076(j) = n.

Examples

			The array starts:
    2,    7,   13,   19,   23,   29,   37,   43,   47,   53,...
    3,   17,   41,   67,   83,  109,  157,  191,  211,  241,...
    5,   59,  179,  331,  431,  599,  919, 1153, 1297, 1523,...
   11,  277, 1063, 2221, 3001, 4397, 7193, 9319,10631,12763,...
   31, 1787, 8527,19577,27457,42043,72727,96797,112129,137077,...
		

Crossrefs

Cf. A007821 (row 1), A049078 (row 2), A049079 (row 3), A007097 (column 1), A058010 (diagonal), A057456 - A057457 (columns), A135044, A236536.

Programs

  • Maple
    A236542 := proc(n,k)
        option remember ;
        if n = 1 then
            A007821(k) ;
        else
            ithprime(procname(n-1,k)) ;
        end if:
    end proc:
    for d from 2 to 10 do
        for k from d-1 to 1 by -1 do
                printf("%d,",A236542(d-k,k)) ;
        end do:
    end do:
  • Mathematica
    A007821 = Prime[Select[Range[15], !PrimeQ[#]&]];
    T[n_, k_] := T[n, k] = If[n == 1, If[k <= Length[A007821], A007821[[k]], Print["A007821 must be extended"]; Abort[]], Prime[T[n-1, k]]];
    Table[T[n-k+1, k], {n, 1, 9}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Apr 16 2020 *)

Formula

T(1,k) = A007821(k).
T(n,k) = prime( T(n-1,k) ), n>1 .

A136043 Period-lengths of the base-2 MR-expansions of the reciprocals of the positive integers.

Original entry on oeis.org

1, 1, 1, 1, 2, 1, 1, 1, 3, 2, 5, 1, 6, 1, 1, 1, 4, 3, 9, 2, 2, 5, 4, 1, 10, 6, 9, 1, 14, 1, 1, 1, 5, 4, 5, 3, 18, 9, 4, 2, 10, 2, 7, 5, 5, 4, 9, 1, 10, 10, 2, 6, 26, 9, 8, 1, 9, 14, 29, 1, 30, 1, 1, 1, 6, 5, 33, 4, 11, 5, 14, 3, 3, 18, 9, 9, 15, 4, 17, 2, 27, 10, 41, 2, 2, 7, 11, 5, 4, 5, 4, 4, 3, 9, 14
Offset: 1

Views

Author

John W. Layman, Dec 12 2007

Keywords

Comments

It appears that if p is a prime with 2 as a primitive root (A001122), then a(p)=(p-1)/2. This has been confirmed for primes up to 2000. See A136042 for the definition of the MR-expansion of a positive real number.

Examples

			In A136042 it is shown that the base-2 MR-expansion of 1/5 is {3,1,3,1,3,1,3,1,...}, with period-length 2, so a(5)=2.
		

Crossrefs

Formula

a(n) = 1 if n is a power of 2. It seems that otherwise a(n) = A119513(n). - Andrei Zabolotskii, Jul 28 2025

A236536 Array T(n,k) read along antidiagonals: the composites of order of compositeness n in row n.

Original entry on oeis.org

4, 6, 9, 8, 12, 16, 10, 15, 21, 26, 14, 18, 25, 33, 39, 20, 24, 28, 38, 49, 56, 22, 32, 36, 42, 55, 69, 78, 27, 34, 48, 52, 60, 77, 94, 106, 30, 40, 50, 68, 74, 84, 105, 125, 141, 35, 45, 57, 70, 93, 100, 115, 140, 164, 184, 44, 51, 64, 80, 95, 124, 133, 152, 183, 212, 236, 46, 63, 72, 88, 110, 126, 162, 174, 198, 235, 270, 299
Offset: 1

Views

Author

R. J. Mathar, Jan 28 2014

Keywords

Comments

Row n contains the composites A002808(j) for which A059981(j) = n.
The 1st row contains the composites with a nonprime index, A002808(1)=4, A002808(2)=6, A002808(3)=8, A002808(5)=10, A002808(7)=14,...
The 2nd row contains the composites with an index in the 1st row.
Recursively the followup rows contain the composites that need a higher number of applications of A002808 to reach a nonprime.

Examples

			The array starts:
  4,  6,  8, 10, 14, 20, 22, 27, 30, 35,...
  9, 12, 15, 18, 24, 32, 34, 40, 45, 51,...
 16, 21, 25, 28, 36, 48, 50, 57, 64, 72,...
 26, 33, 38, 42, 52, 68, 70, 80, 88, 98,...
 39, 49, 55, 60, 74, 93, 95,110,119,130,...
 56, 69, 77, 84,100,124,126,145,156,170,...
 78, 94,105,115,133,162,165,188,203,218,...
106,125,140,152,174,209,213,242,259,278,...
141,164,183,198,222,266,272,305,326,348,...
		

Crossrefs

Cf. A006508 (column 1), A022449 (row 1), A135044, A236542, A002808.

Programs

  • Maple
    A236536 := proc(n,k)
        option remember ;
        if n = 1 then
            A022449(k) ;
        else
            A002808(procname(n-1,k)) ;
        end if:
    end proc:
    for d from 2 to 10 do
         for k from d-1 to  by -1 do
            printf("%3d,",A236536(d-k,k)) ;
         end do:
    end do:
  • Mathematica
    Composite[n_] := FixedPoint[n + PrimePi[#] + 1&, n + PrimePi[n] + 1];
    T[n_, k_] := T[n, k] = If[n == 1, Composite[If[k == 1, 1, Prime[k - 1]]], Composite[T[n - 1, k]]];
    Table[T[n - k + 1, k], {n, 1, 12}, {k, n, 1, -1}] // Flatten (* Jean-François Alcover, Sep 16 2023 *)

Formula

T(1,k) = A022449(k).
T(n,k) = A002808( T(n-1,k) ), n>1 .
Showing 1-4 of 4 results.