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

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)

A066246 a(n) = 0 unless n is a composite number A002808(k) then a(n) = k.

Original entry on oeis.org

0, 0, 0, 1, 0, 2, 0, 3, 4, 5, 0, 6, 0, 7, 8, 9, 0, 10, 0, 11, 12, 13, 0, 14, 15, 16, 17, 18, 0, 19, 0, 20, 21, 22, 23, 24, 0, 25, 26, 27, 0, 28, 0, 29, 30, 31, 0, 32, 33, 34, 35, 36, 0, 37, 38, 39, 40, 41, 0, 42, 0, 43, 44, 45, 46, 47, 0, 48, 49, 50, 0, 51, 0, 52, 53, 54, 55, 56, 0, 57
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 09 2001

Keywords

Crossrefs

Programs

  • Haskell
    import Data.List (unfoldr, genericIndex)
    a066246 n = genericIndex a066246_list (n - 1)
    a066246_list = unfoldr x (1, 1, a002808_list) where
       x (i, z, cs'@(c:cs)) | i == c = Just (z, (i + 1, z + 1, cs))
                            | i /= c = Just (0, (i + 1, z, cs'))
    -- Reinhard Zumkeller, Jan 29 2014
  • Mathematica
    Module[{k=1},Table[If[CompositeQ[n],k;k++,0],{n,100}]] (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Jan 03 2019 *)
  • PARI
    a(n)=if(isprime(n),0,max(0,n-primepi(n)-1)) \\ Charles R Greathouse IV, Aug 21 2011
    

Formula

a(n) = A239968(n) + A010051(n) - 1. - Reinhard Zumkeller, Mar 30 2014
a(n) = A065855(n)*A005171(n). - Ridouane Oudra, Jul 29 2025

A026233 a(n) = j if n is the j-th prime, else a(n) = k if n is the k-th nonprime.

Original entry on oeis.org

1, 1, 2, 2, 3, 3, 4, 4, 5, 6, 5, 7, 6, 8, 9, 10, 7, 11, 8, 12, 13, 14, 9, 15, 16, 17, 18, 19, 10, 20, 11, 21, 22, 23, 24, 25, 12, 26, 27, 28, 13, 29, 14, 30, 31, 32, 15, 33, 34, 35, 36, 37, 16, 38, 39, 40, 41, 42, 17, 43, 18, 44, 45, 46, 47, 48
Offset: 1

Views

Author

Keywords

Comments

Each n occurs at two positions, the distances between them are: 1, 1, 1, 1, 2, 3, 5, 5, 8, 13, 13, 17, 20, 21, 23, 28, 33, 34, 39, 41, 41, ... - Zak Seidov, Mar 06 2011

Crossrefs

Cf. A026238.

Programs

  • Haskell
    a026233 n = a049084 n + a239968 n
    -- Reinhard Zumkeller, Mar 30 2014, Feb 12 2014
    
  • Mathematica
    m=100;pr=Prime[Range[m]];npr=Select[Range[m],!PrimeQ[#]&];
    a[n_]:=If[PrimeQ[n],PrimePi[n],Position[npr,n][[1,1]]]; Table[a[n],{n,m}] (* Zak Seidov Mar 05 2011 *) s=Range[500];Do[s=Insert[s,n,Prime[n]],{n,100}];s (* Zak Seidov, Mar 05 2011 *)
  • PARI
    first(n)=my(p,c); vector(n,k,if(isprime(k),p++,c++)) \\ Charles R Greathouse IV, Sep 02 2015

Formula

a(n) = A049084(n) + A066246(n) + A000007(A010051(n)). - Reinhard Zumkeller, Feb 12 2014
a(n) = A049084(n) + A239968(n). - Reinhard Zumkeller, Mar 30 2014

A066248 a(n) = if n+1 is prime then A049084(n+1)*2 else A066246(n+1)*2 - 1.

Original entry on oeis.org

2, 4, 1, 6, 3, 8, 5, 7, 9, 10, 11, 12, 13, 15, 17, 14, 19, 16, 21, 23, 25, 18, 27, 29, 31, 33, 35, 20, 37, 22, 39, 41, 43, 45, 47, 24, 49, 51, 53, 26, 55, 28, 57, 59, 61, 30, 63, 65, 67, 69, 71, 32, 73, 75, 77, 79, 81, 34, 83, 36, 85, 87, 89, 91, 93, 38, 95, 97, 99, 40, 101, 42
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 09 2001

Keywords

Comments

Permutation of natural numbers; inverse: A066249.

Crossrefs

Programs

  • Mathematica
    a[n_] := If[PrimeQ[n+1], 2 * PrimePi[n+1], 2 * (n - PrimePi[n+1]) - 1]; Array[a, 100] (* Amiram Eldar, Mar 19 2025 *)

Formula

a(n) = A026238(n+1)*2 - A066247(n+1).

A066136 Primes are replaced by their local sequence number in A000040, while composites are replaced by their sequence number in A002808; (a kind of eigen- or home-indexing).

Original entry on oeis.org

0, 1, 2, 1, 3, 2, 4, 3, 4, 5, 5, 6, 6, 7, 8, 9, 7, 10, 8, 11, 12, 13, 9, 14, 15, 16, 17, 18, 10, 19, 11, 20, 21, 22, 23, 24, 12, 25, 26, 27, 13, 28, 14, 29, 30, 31, 15, 32, 33, 34, 35, 36, 16, 37, 38, 39, 40, 41, 17, 42, 18, 43, 44, 45, 46, 47, 19, 48, 49, 50, 20, 51, 21, 52, 53
Offset: 1

Views

Author

Labos Elemer, Dec 07 2001

Keywords

Comments

Primality or compositeness is recognizable from the terms: if successor of a term(>2) is larger by one than the term, then it labels a composite number.

Crossrefs

Programs

  • Mathematica
    Do[s=n; If[PrimeQ[n], Print[PrimePi[n]]]; If[ !PrimeQ[n], Print[n-PrimePi[n]-1]], {n, 1, 1000}]
  • PARI
    a(n) = { if (isprime(n), primepi(n), n - primepi(n) - 1) } \\ Harry J. Smith, Feb 02 2010

Formula

a(n) = pi(n) if n is prime; a(n) = n-pi(n)-1 if n is not prime.
a(n) = A026238(n), n>1. - R. J. Mathar, Sep 30 2008

A066250 a(n) = if n+1 is prime then A049084(n+1)*2 - 1 else A066246(n+1)*2.

Original entry on oeis.org

1, 3, 2, 5, 4, 7, 6, 8, 10, 9, 12, 11, 14, 16, 18, 13, 20, 15, 22, 24, 26, 17, 28, 30, 32, 34, 36, 19, 38, 21, 40, 42, 44, 46, 48, 23, 50, 52, 54, 25, 56, 27, 58, 60, 62, 29, 64, 66, 68, 70, 72, 31, 74, 76, 78, 80, 82, 33, 84, 35, 86, 88, 90, 92, 94, 37, 96, 98, 100, 39, 102
Offset: 1

Views

Author

Reinhard Zumkeller, Dec 09 2001

Keywords

Comments

Permutation of natural numbers; inverse: A066251.

Crossrefs

Formula

a(n) = A026238(n+1)*2 - A010051(n+1).
Showing 1-6 of 6 results.