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-2 of 2 results.

A026234 In the sequence of positive integers, swap the k-th prime and k-th nonprime, for k = 1,2,3,...

Original entry on oeis.org

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

Views

Author

Keywords

Comments

A permutation of the positive integers. - M. F. Hasler, Jan 29 2014

Examples

			a(1) = 2 because 1 is not prime and the first prime is 2.
a(2) = 1 because 2 is prime and the first nonprime is 1.
a(3) = 4 because 3 is prime and the second nonprime is 4.
a(4) = 3 because 4 is not prime and the second prime is 3.
a(5) = 6 because 5 is prime and the third nonprime is 6.
		

Crossrefs

Programs

  • Mathematica
    nonPrimePi[n_] := n - PrimePi[n]; nonPrime[n_] := FixedPoint[n + PrimePi[#] &, n + PrimePi[n]]; A026234[n_] := If[PrimeQ[n], nonPrime[PrimePi[n]], Prime[nonPrimePi[n]]]; Table[A026234[n], {n, 200}] (* Enrique Pérez Herrero, Jan 28 2014 *)
  • PARI
    c=p=0;vector(99,n,if(isprime(n),while(isprime(c++),);c,prime(p++))) \\ M. F. Hasler, Jan 29 2014
    
  • PARI
    A026234 = n->if(isprime(n),A018252(primepi(n)),prime(n-primepi(n))) \\ M. F. Hasler, Jan 29 2014

Formula

If n is prime, then a(n) = A018252(n), else a(n) = A000040(n). - M. F. Hasler, Jan 29 2014

A236676 The n-th term is the n-th composite if n is prime, and the n-th prime if n is not prime.

Original entry on oeis.org

2, 6, 8, 7, 10, 13, 14, 19, 23, 29, 20, 37, 22, 43, 47, 53, 27, 61, 30, 71, 73, 79, 35, 89, 97, 101, 103, 107, 44, 113, 46, 131, 137, 139, 149, 151, 54, 163, 167, 173, 58, 181, 62, 193, 197, 199, 66, 223, 227, 229, 233, 239, 75, 251, 257, 263, 269, 271, 82
Offset: 1

Views

Author

M. F. Hasler, Jan 29 2014

Keywords

Comments

See A097457 for the (maybe more natural) variant where "n-th composite"(=A002808(n)) is replaced by "n-th nonprime" (=A018252(n)).
Essentially the same as A088608. - R. J. Mathar, Feb 03 2014

Crossrefs

Programs

  • Mathematica
    Module[{nn=100,prs,cmps,len},cmps=Select[Range[nn],CompositeQ];len= Length[ cmps];prs=Prime[Range[len]];Table[If[PrimeQ[n],cmps[[n]],prs[[n]]],{n,len}]] (* Harvey P. Dale, Dec 27 2022 *)
  • PARI
    A236676 = n->if(isprime(n),A002808(n),prime(n))

Formula

a(n) = A002808(n) if n is prime, a(n) = A000040(n) else.
Showing 1-2 of 2 results.