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-10 of 13 results. Next

A135141 a(1)=1, a(p_n)=2*a(n), a(c_n)=2*a(n)+1, where p_n = n-th prime, c_n = n-th composite number.

Original entry on oeis.org

1, 2, 4, 3, 8, 5, 6, 9, 7, 17, 16, 11, 10, 13, 19, 15, 12, 35, 18, 33, 23, 21, 14, 27, 39, 31, 25, 71, 34, 37, 32, 67, 47, 43, 29, 55, 22, 79, 63, 51, 20, 143, 26, 69, 75, 65, 38, 135, 95, 87, 59, 111, 30, 45, 159, 127, 103, 41, 24, 287, 70, 53, 139, 151, 131, 77, 36, 271, 191
Offset: 1

Views

Author

Katarzyna Matylla, Feb 13 2008

Keywords

Comments

A permutation of the positive integers, related to A078442.
a(p) is even when p is prime and is divisible by 2^(prime order of p).
From Robert G. Wilson v, Feb 16 2008: (Start)
What is the length of the cycle containing 10? Is it infinite? The cycle begins 10, 17, 12, 11, 16, 15, 19, 18, 35, 29, 34, 43, 26, 31, 32, 67, 36, 55, 159, 1055, 441, 563, 100, 447, 7935, 274726911, 1013992070762272391167, ... Implementation in Mmca: NestList[a(AT)# &, 10, 26] Furthermore, it appears that any non-single-digit number has an infinite cycle.
Records: 1, 2, 4, 8, 9, 17, 19, 35, 39, 71, 79, 143, 159, 287, 319, 575, 639, 1151, 1279, 2303, 2559, 4607, 5119, 9215, 10239, 18431, 20479, 36863, 40959, 73727, 81919, 147455, 163839, 294911, 327679, 589823, 655359, ..., . (End)

Examples

			a(20) = 33 = 2*16 + 1 because 20 is 11th composite and a(11)=16. Or, a(20)=33=100001(bin). In other words it is a composite number, its index is a prime number, whose index is a prime....
		

Crossrefs

Cf. A246346, A246347 (record positions and values).
Cf. A227413 (inverse).
Cf. A071574, A245701, A245702, A245703, A245704, A246377, A236854, A237427 for related and similar permutations.

Programs

  • Haskell
    import Data.List (genericIndex)
    a135141 n = genericIndex a135141_list (n-1)
    a135141_list = 1 : map f [2..] where
       f x | iprime == 0 = 2 * (a135141 $ a066246 x) + 1
           | otherwise   = 2 * (a135141 iprime)
           where iprime = a049084 x
    -- Reinhard Zumkeller, Jan 29 2014
    
  • Mathematica
    a[1] = 1; a[n_] := If[PrimeQ@n, 2*a[PrimePi[n]], 2*a[n - 1 - PrimePi@n] + 1]; Array[a, 69] (* Robert G. Wilson v, Feb 16 2008 *)
  • Maxima
    /* Let pc = prime count (which prime it is), cc = composite count: */
    pc[1]:0;
    cc[1]:0;
    pc[2]:1;
    cc[4]:1;
    pc[n]:=if primep(n) then 1+pc[prev_prime(n)] else 0;
    cc[n]:=if primep(n) then 0 else if primep(n-1) then 1+cc[n-2] else 1+cc[n-1];
    a[1]:1;
    a[n]:=if primep(n) then 2*a[pc[n]] else 1+2*a[cc[n]];
    
  • PARI
    A135141(n) = if(1==n, 1, if(isprime(n), 2*A135141(primepi(n)), 1+(2*A135141(n-primepi(n)-1)))); \\ Antti Karttunen, Dec 09 2019
  • Python
    from sympy import isprime, primepi
    def a(n): return 1 if n==1 else 2*a(primepi(n)) if isprime(n) else 2*a(n - 1 - primepi(n)) + 1 # Indranil Ghosh, Jun 11 2017, after Mathematica code
    

Formula

a(n) = 2*A135141((A049084(n))*chip + A066246(n)*(1-chip)) + 1 - chip, where chip = A010051(n). - Reinhard Zumkeller, Jan 29 2014
From Antti Karttunen, Dec 09 2019: (Start)
A007814(a(n)) = A078442(n).
A070939(a(n)) = A246348(n).
A080791(a(n)) = A246370(n).
A054429(a(n)) = A246377(n).
A245702(a(n)) = A245703(n).
a(A245704(n)) = A245701(n). (End)

A246377 Permutation of natural numbers: a(1) = 1, a(p_n) = 2*a(n)+1, a(c_n) = 2*a(n), where p_n = n-th prime = A000040(n), c_n = n-th composite number = A002808(n).

Original entry on oeis.org

1, 3, 7, 2, 15, 6, 5, 14, 4, 30, 31, 12, 13, 10, 28, 8, 11, 60, 29, 62, 24, 26, 9, 20, 56, 16, 22, 120, 61, 58, 63, 124, 48, 52, 18, 40, 25, 112, 32, 44, 27, 240, 21, 122, 116, 126, 57, 248, 96, 104, 36, 80, 17, 50, 224, 64, 88, 54, 23, 480, 121, 42, 244, 232, 252, 114, 59, 496, 192, 208, 125, 72, 49, 160, 34, 100
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Comments

This permutation is otherwise like Katarzyna Matylla's A135141, except that the role of even and odd numbers (or alternatively: primes and composites) has been swapped.
Because 2 is the only even prime, it implies that, apart from a(2)=3, odd numbers occur in odd positions only (along with many even numbers that also occur in odd positions).
This also implies that for each odd composite (A071904) there exists a separate infinite cycle in this permutation, apart from 9 and 15 which are in the same infinite cycle: (..., 23, 9, 4, 2, 3, 7, 5, 15, 28, 120, 82, 46, ...).

Crossrefs

Inverse: A246378.
Other related or similar permutations: A135141, A054429, A246201, A245703, A246376, A246379, A243071, A246681, A236854.
Differs from A237427 for the first time at n=19, where a(19) = 29, while A237427(19) = 62.

Formula

a(1) = 1, and for n > 1, if A010051(n) = 1 [i.e. when n is a prime], a(n) = 1+(2*a(A000720(n))), otherwise a(n) = 2*a(A065855(n)).
As a composition of related permutations:
a(n) = A054429(A135141(n)).
a(n) = A135141(A236854(n)).
a(n) = A246376(A246379(n)).
a(n) = A246201(A245703(n)).
a(n) = A243071(A246681(n)). [For n >= 1].
Other identities.
For all n > 1 the following holds:
A000035(a(n)) = A010051(n). [Maps primes to odd numbers > 1, and composites to even numbers, in some order. Permutations A246379 & A246681 have the same property].

A246378 Permutation of natural numbers: a(1) = 1, a(2n) = nthcomposite(a(n)), a(2n+1) = nthprime(a(n)), where nthcomposite = A002808, nthprime = A000040.

Original entry on oeis.org

1, 4, 2, 9, 7, 6, 3, 16, 23, 14, 17, 12, 13, 8, 5, 26, 53, 35, 83, 24, 43, 27, 59, 21, 37, 22, 41, 15, 19, 10, 11, 39, 101, 75, 241, 51, 149, 114, 431, 36, 89, 62, 191, 40, 103, 82, 277, 33, 73, 54, 157, 34, 79, 58, 179, 25, 47, 30, 67, 18, 29, 20, 31, 56, 167, 134, 547, 102, 379, 304, 1523, 72, 233
Offset: 1

Views

Author

Antti Karttunen, Aug 27 2014

Keywords

Comments

Contains an infinite number of infinite cycles. See comments at A246377.

Crossrefs

Inverse: A246377.
Similar or related permutations: A237126, A054429, A227413, A236854, A246375, A246380, A246682, A163511.

Programs

Formula

a(1) = 1, a(2n) = nthcomposite(a(n)), a(2n+1) = nthprime(a(n)), where nthcomposite = A002808, nthprime = A000040.
As a composition of related permutations:
a(n) = A227413(A054429(n)).
a(n) = A236854(A227413(n)).
a(n) = A246380(A246375(n)).
a(n) = A246682(A163511(n)). [For n >= 1].
Other identities. For all n > 1 the following holds:
A010051(a(n)) = A000035(n). [Maps odd numbers larger than one to primes, and even numbers to composites, in some order. Permutations A246380 & A246682 have the same property].

A244319 Self-inverse permutation of natural numbers: a(1) = 1, a(2n) = A003961(1+a(A064989(2n-1))), a(2n+1) = 1+A003961(a(A064989(2n+1)-1)).

Original entry on oeis.org

1, 3, 2, 9, 6, 5, 26, 11, 4, 21, 8, 125, 56, 25, 16, 15, 344, 115, 36, 1015, 10, 39, 204, 41, 14, 7, 52, 45, 86, 301, 176, 155, 298, 51, 50, 19, 518, 305, 22, 189, 24, 895, 1376, 49, 28, 825, 1268, 11875, 44, 35, 34, 27, 3186, 6625, 2388, 13, 454, 153, 126, 3191, 476, 131
Offset: 1

Views

Author

Antti Karttunen, Jul 18 2014; description corrected and PARI code added Jul 30 2014

Keywords

Comments

After 1, maps each even number to a unique odd number and vice versa, i.e., for all n > 1, A000035(a(n)) XOR A000035(n) = 1, where XOR is given in A003987.

Crossrefs

Related permutations: A048673, A064216, A245609-A245610.
Similar entanglement permutations: A245605-A245606, A235491, A236854, A243347, A244152.

Programs

Formula

a(1) = 1, a(2n) = A003961(1+a(A064989(2n-1))), a(2n+1) = A243501(a(A064989(2n+1)-1)).
As a composition of related permutations:
a(n) = A245609(A048673(n)) = A064216(A245610(n)).

A243347 a(1)=1, and for n>1, if mu(n) = 0, a(n) = A005117(1+a(A057627(n))), otherwise, a(n) = A013929(a(A013928(n))).

Original entry on oeis.org

1, 4, 12, 2, 32, 8, 84, 6, 19, 24, 220, 3, 18, 50, 63, 53, 564, 13, 9, 138, 49, 128, 162, 10, 31, 136, 38, 365, 1448, 36, 25, 5, 351, 126, 332, 30, 414, 27, 81, 82, 348, 99, 931, 103, 86, 3699, 96, 929, 21, 14, 64, 223, 16, 79, 892, 210, 325, 847, 80, 265, 1056, 72, 15, 51, 208, 212, 884, 221, 256
Offset: 1

Views

Author

Antti Karttunen, Jun 03 2014

Keywords

Comments

Self-inverse permutation of natural numbers.
Shares with A088609 the property that after 1, positions indexed by squarefree numbers larger than one, A005117(n+1): 2, 3, 5, 6, 7, 10, 11, 13, 14, ... contain only nonsquarefree numbers A013929: 4, 8, 9, 12, 16, 18, 20, 24, ..., and vice versa. 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, thus implementing a kind of "deep" variant of A088609. Alternatively, this can be viewed as yet another "entanglement permutation", where two pairs of complementary subsets of natural numbers are interwoven with each other. In this case complementary pair A005117/A013929 is entangled with complementary pair A013929/A005117.

Crossrefs

Formula

a(1), and for n>1, if mu(n) = 0, a(n) = A005117(1+a(A057627(n))), otherwise, a(n) = A013929(a(A013928(n))). [Here mu is Moebius mu-function, A008683, which is zero only when n is a nonsquarefree number, one of the numbers in A013929.]
For all n > 1, A008966(a(n)) = 1 - A008966(n), or equally, mu(a(n)) + 1 = mu(n) modulo 2, where mu is Moebius mu (A008683). [Note: Permutation A088609 satisfies the same condition.]

A026239 Beginning with the natural numbers, swap the k-th prime and k-th composite.

Original entry on oeis.org

1, 4, 6, 2, 8, 3, 9, 5, 7, 11, 10, 13, 12, 17, 19, 23, 14, 29, 15, 31, 37, 41, 16, 43, 47, 53, 59, 61, 18, 67, 20, 71, 73, 79, 83, 89, 21, 97, 101, 103, 22, 107, 24, 109, 113, 127, 25, 131, 137, 139, 149, 151, 26, 157, 163, 167, 173, 179, 27, 181, 28, 191, 193, 197, 199
Offset: 1

Views

Author

Keywords

Comments

Involution (self-inverse permutation) of [positive] natural numbers.

Crossrefs

Cf. A236854.

Programs

  • Haskell
    a026239 1 = 1
    a026239 n | a010051 n == 1 = a002808 $ a049084 n
              | otherwise      = a000040 $ a066246 n
    -- Reinhard Zumkeller, Mar 30 2014
  • Mathematica
    Composite[n_Integer] := FixedPoint[n + PrimePi@# + 1 &, n + PrimePi@n + 1]; f[1] = 1; f[n_] := If[ PrimeQ@n, Composite@ PrimePi@n, Prime[n - 1 - PrimePi@n]]; Array[f, 65] (* Robert G. Wilson v, Jun 08 2010 *)

Formula

a(1) = 1 and a(n) = if n is prime then A002808(A049084(n)) else A000040(A066246(n)) for n>1. - Reinhard Zumkeller, Dec 13 2001

Extensions

More terms from Robert G. Wilson v, Jun 08 2010

A235491 Self-inverse permutation of natural numbers: complementary pair ludic/nonludic numbers (A003309/A192607) entangled with the same pair in the opposite order, nonludic/ludic. See Formula.

Original entry on oeis.org

0, 1, 4, 9, 2, 16, 7, 6, 25, 3, 61, 26, 17, 14, 13, 115, 5, 12, 359, 119, 67, 47, 43, 36, 791, 8, 11, 41, 3017, 81, 811, 407, 247, 227, 179, 7525, 23, 38, 37, 221, 34015, 27, 503, 22, 7765, 3509, 1943, 21, 1777, 1333, 93625, 97, 193, 146, 181, 1717, 486721, 121, 4493, 91, 96839, 10, 40217, 20813, 89
Offset: 0

Views

Author

Antti Karttunen, Feb 07 2014

Keywords

Comments

The permutation is self-inverse (an involution), meaning that a(a(n)) = n for all n.

Examples

			For n=2, with 2 being the second ludic number (= A003309(4)), the value is computed as nonludic(a(2-1)) = nonludic(a(1)) = 4, the first nonludic number, thus a(2) = 4.
For n=5, with 5 being the fourth ludic number (= A003309(4)), the value is computed as nonludic(a(4-1)) = nonludic(a(3)) = nonludic(9) = 16, thus a(5) = 16.
For n=6, with 6 being the second nonludic number (= A192607(2)), the value is computed as ludic(a(2)+1) = ludic(4+1) = ludic(5) = 7, thus a(6) = 7.
		

Crossrefs

Cf. A236854 (a similar permutation constructed from prime and composite numbers).
Cf. A237126/A237427 (entanglement permutations between ludic/nonludic <-> odd/even numbers).

Formula

a(0)=0, a(1)=1, and for n > 1, if n is k-th ludic number (i.e., n = A003309(k)), then a(n) = nonludic(a(k-1)); otherwise, when n is k-th nonludic number (i.e., n = A192607(k)), then a(n) = ludic(a(k)+1), where ludic numbers are given by A003309, and nonludic numbers by A192607.
a(0)=0, a(1)=1, and for n > 1, if A192490(n)=1 (n is ludic) a(n) = A192607(a(A192512(n)-1)); otherwise (n is nonludic), a(n) = A003309(1+(a(A236863(n)))).

A244152 Self-inverse permutation of natural numbers: a(1) = 1; thereafter, if n is k-th number with an odd number of prime divisors (counted with multiplicity) [i.e., n = A026424(k)], a(n) = A028260(1+a(k)), otherwise, when n is k-th number > 1 with an even number of prime divisors [i.e., n = A028260(1+k)], a(n) = A026424(a(k)).

Original entry on oeis.org

1, 4, 10, 2, 24, 7, 6, 55, 18, 3, 16, 15, 121, 44, 12, 11, 39, 9, 36, 35, 105, 31, 250, 5, 29, 28, 93, 26, 25, 86, 22, 82, 238, 79, 20, 19, 81, 72, 17, 68, 218, 65, 517, 14, 62, 67, 60, 202, 195, 57, 59, 56, 185, 477, 8, 52, 50, 175, 51, 47, 177, 45, 495, 167, 42, 161, 46, 40, 162, 169, 150, 38, 143, 455, 459, 140, 153, 1060, 34, 134, 37, 32
Offset: 1

Views

Author

Antti Karttunen, Jul 27 2014

Keywords

Crossrefs

Similar entanglement permutations: A245603-A245604, A235491, A236854, A243347, A244319.

Formula

a(1) = 1, and for n > 1, if A066829(n) = 1, then a(n) = A028260(1 + A244152(A055038(n))), otherwise a(n) = A026424(A244152(A055037(n)-1)).
For all n > 1, A008836(a(n)) = -1 * A008836(n), where A008836 is Liouville's lambda-function.

A135044 a(1)=1, then a(c) = p and a(p) = c, where c = T_c(r,k) and p = T_p(r,k), and where T_p contains the primes arranged in rows by the prime index chain and T_c contains the composites arranged in rows by the order of compositeness. See Formula.

Original entry on oeis.org

1, 4, 9, 2, 16, 7, 6, 13, 3, 19, 26, 17, 8, 23, 41, 5, 12, 67, 10, 29, 59, 37, 14, 83, 179, 11, 43, 331, 20, 47, 39, 109, 277, 157, 53, 431, 22, 1063, 31, 191, 15, 2221, 27, 61, 211, 71, 30, 599, 1787, 919, 241, 3001, 35, 73, 8527, 127, 1153, 79, 21, 19577, 44, 89, 283
Offset: 1

Views

Author

Katarzyna Matylla, Feb 11 2008

Keywords

Comments

Exchanges primes with composites, primeth primes with composith composites, etc.
Exchange the k-th prime of order j with the k-th composite of order j and vice versa.
Self-inverse permutation of positive integers.
If n is the composite number A236536(r,k), then a(n) is the corresponding prime A236542(r,k) at the same position (r,k). Vice versa, if n is the prime A236542(r,k), then a(n) is the corresponding composite A236536(r,k) at the same position. - Andrew Weimholt, Jan 28 2014
The original name for this entry did not produce this sequence, but instead A236854, which differs from this permutation for the first time at n=8, where A236854(8)=23, while here a(8)=13. - Antti Karttunen, Feb 01 2014

Examples

			From _Andrew Weimholt_, Jan 29 2014: (Start)
More generally, takes the primes organized in an array according to the sieving process described in the Fernandez paper:
        Row[1](n) = 2, 7, 13, 19, 23, ...
        Row[2](n) = 3, 17, 41, 67, 83, ...
        Row[3](n) = 5, 59, 179, ...
        Row[4](n) = 11, 277, ...
        Lets call this  T_p (n, k)
Also take the composites organized in a similar manner, except we use "composite" numbered positions in our sieve:
        Row[1](n) = 4, 6, 8, 10, 14, 20, 22, ...
        Row[2](n) = 9, 12, 15, 18, 24, ...
        Row[3](n) = 16, 21, 25, ...
        Lets call this T_c (n, k)
If we now take the natural numbers and swap each number (except for 1) with the number which holds the same spot in the other array, then we get the sequence: 1, 4, 9, 2, 16, 7, 6, 13, with for example a(8) = 13 (13 holds the same position in the 'prime' table as 8 does in the 'composite' table). (End)
		

Crossrefs

Programs

  • Maple
    A135044 := proc(n)
        if n = 1 then
            1;
        elif isprime(n) then
            idx := -1 ;
            for r from 1 do
                for c from 1 do
                    if A236542(r,c) = n then
                        idx := [r,c] ;
                    end if;
                    if A236542(r,c) >= n then
                        break;
                    end if;
                end do:
                if type(idx,list)  then
                    break;
                end if;
            end do:
            A236536(r,c) ;
        else
            idx := -1 ;
            for r from 1 do
                for c from 1 do
                    if A236536(r,c) = n then
                        idx := [r,c] ;
                    end if;
                    if A236536(r,c) >= n then
                        break;
                    end if;
                end do:
                if type(idx,list)  then
                    break;
                end if;
            end do:
            A236542(r,c) ;
        end if;
    end proc: # R. J. Mathar, Jan 28 2014
  • Mathematica
    Composite[n_Integer] := Block[{k = n + PrimePi@n + 1}, While[k != n + PrimePi@k + 1, k++ ]; k]; Compositeness[n_] := Block[{c = 1, k = n}, While[ !(PrimeQ@k || k == 1), k = k - 1 - PrimePi@k; c++ ]; c]; Primeness[n_] := Block[{c = 1, k = n}, While[ PrimeQ@k, k = PrimePi@k; c++ ]; c];
    ckj[k_, j_] := Select[ Table[Composite@n, {n, 10000}], Compositeness@# == j &][[k]]; pkj[k_, j_] := Select[ Table[Prime@n, {n, 3000}], Primeness@# == j &][[k]]; f[0]=0; f[1] = 1;
    f[n_] := If[ PrimeQ@ n, pn = Primeness@n; ckj[ Position[ Select[ Table[ Prime@ i, {i, 150}], Primeness@ # == pn &], n][[1, 1]], pn], cn = Compositeness@n; pkj[ Position[ Select[ Table[ Composite@ i, {i, 500}], Compositeness@ # == cn &], n][[1, 1]], cn]]; Array[f, 64] (* Robert G. Wilson v *)

Formula

a(1)=1, a(A236536(r,k))=A236542(r,k), a(A236542(r,k))=A236536(r,k)

Extensions

Edited, corrected and extended by Robert G. Wilson v, Feb 18 2008
Name corrected by Andrew Weimholt, Jan 29 2014

A257730 Permutation of natural numbers: a(1)=1; a(oddprime(n)) = prime(a(n)), a(not_an_oddprime(n)) = composite(a(n-1)).

Original entry on oeis.org

1, 4, 2, 9, 7, 6, 3, 16, 14, 12, 23, 8, 17, 26, 24, 21, 13, 35, 5, 15, 27, 39, 53, 36, 33, 22, 51, 10, 43, 25, 37, 40, 56, 75, 52, 49, 83, 34, 72, 18, 19, 62, 59, 38, 54, 57, 101, 78, 102, 74, 69, 114, 89, 50, 98, 28, 30, 86, 73, 82, 41, 55, 76, 80, 134, 106, 149, 135, 100, 94, 11, 150, 47, 120, 70, 130, 42, 45, 103, 117, 99, 112, 167, 58, 77
Offset: 1

Views

Author

Antti Karttunen, May 09 2015

Keywords

Comments

Here composite(n) = n-th composite = A002808(n), prime(n) = n-th prime = A000040(n), oddprime(n) = n-th odd prime = A065091(n) = A000040(n+1), not_an_oddprime(n) = n-th natural number which is not an odd prime = A065090(n).

Crossrefs

Inverse: A257729.
Related or similar permutations: A246378, A257727, A257732, A257801, A236854.

Formula

a(1) = 1; if A000035(n) = 1 and A010051(n) = 1 [i.e., when n is an odd prime], then a(n) = A000040(a(A000720(n)-1)), otherwise a(n) = A002808(a(A062298(n))). [Here A062298(n) gives the index of n among numbers larger than 1 which are not odd primes, 1 for 2, 2 for 4, 3 for 6, etc.]
As a composition of other permutations:
a(n) = A246378(A257727(n)).
a(n) = A257732(A257801(n)).
Showing 1-10 of 13 results. Next