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.

A121053 A sequence S describing the position of its prime terms.

Original entry on oeis.org

2, 3, 5, 1, 7, 8, 11, 13, 10, 17, 19, 14, 23, 29, 16, 31, 37, 20, 41, 43, 22, 47, 53, 25, 59, 27, 61, 30, 67, 71, 73, 33, 79, 35, 83, 38, 89, 97, 40, 101, 103, 44, 107, 109, 46, 113, 127, 49, 131, 51, 137, 54, 139, 149, 56, 151, 58, 157, 163, 62, 167, 173, 64, 179, 66, 181, 191, 69, 193, 72, 197, 199, 211, 75, 223, 77, 227, 80, 229
Offset: 1

Views

Author

Eric Angelini, Aug 10 2006

Keywords

Comments

S reads like this:
"At position 2, there is a prime in S" [indeed, this is 3]
"At position 3, there is a prime in S" [indeed, this is 5]
"At position 5, there is a prime in S" [indeed, this is 7]
"At position 1, there is a prime in S" [indeed, this is 2]
"At position 7, there is a prime in S" [indeed, this is 11]
"At position 8, there is a prime in S" [indeed, this is 13]
"At position 11, there is a prime in S" [indeed, this is 19]
"At position 13, there is a prime in S" [indeed, this is 23]
"At position 10, there is a prime in S" [indeed, this is 17], etc.
S is built with this rule: when you are about to write a term of S, always use the smallest integer not yet present in S and not leading to a contradiction.
Thus one cannot start with 1; this would read: "At position 1, there is a prime number in S" [no, 1 is not a prime]
So start S with 2 and the rest follows smoothly.
S contains all the primes and they appear in their natural order.
Does the ratio primes/composites in S tend to a limit?
The definition and the comments above are Eric Angelini's original submission. A more formal definition would be "Lexicographically earliest sequence of distinct positive numbers such that k is a term of the sequence iff a(k) is a prime". However, to honor Eric Angelini's memory, we will retain his enigmatic definition. - N. J. A. Sloane, Dec 20 2024
Comments from N. J. A. Sloane, Nov 14 2024 (Start)
Theorem. Let p(k) = k-th prime, c(k) = k-th composite number. For n >= 5, if n is a prime or n = c(2*t+1) for some t, then a(n) = p(k) where k = floor((n+PrimePi(n))/2); otherwise, n = c(2*t) for some t and a(n) = c(2*t+1).
The proof will be added later (see reference).
The theorem implies that the sequence consists of the primes and the odd-subscripted composite numbers.
All of Dean Hickerson's comments below follow from this theorem. (End)
Comments from Dean Hickerson, Aug 11 2006: (Start)
In the limit, exactly half of the terms are primes. Here's a formula, found empirically, for a(n) for n >= 5:
Let pi(n) be the number of primes <= n and p(n) be the n-th prime. Then for n >= 5:
- if n is prime or (n is composite and n+pi(n) is even) then a(n) = p(floor((n+pi(n))/2));
- if n is composite and n+pi(n) is odd and n+1 is composite then a(n) = n+1;
- if n is composite and n+pi(n) is odd and n+1 is prime then a(n) = n+2.
Also, for n >= 5, a(n) is in the sequence iff either n is prime or n+pi(n) is even.
(This could all be proved by induction on n.)
It follows from this that, for n >= 4, the number of primes among a(1), ..., a(n) is exactly floor((n+pi(n))/2). Since pi(n)/n -> 0 as n -> infinity, this is asymptotic to n/2. (End)

References

  • N. J. A. Sloane, The Remarkable Sequences of Éric Angelini, MS in preparation, December 2024.

Crossrefs

See A377901 for the analogous sequence if 1 is regarded as a prime.

Programs

  • Maple
    chi := proc(n) if n <= 3 then 0 else n - numtheory:-pi(n) - 1; fi; end; # A065855, number of composites <= n
    A002808 := proc(n) option remember ; local a ; if n = 1 then 4; else for a from procname(n-1)+1 do if not isprime(a) then return a; end if; end do ; end if; end proc;
    A121053 := proc(n) local init,t1;
    init := [2,3,5,1,7];
    if n<=5 then return(init[n]); fi;
    if isprime(n) or (not isprime(n) and ((chi(n) mod 2) = 1))
       then ithprime(floor((n+numtheory:-pi(n))/2));
    else t1 := chi(n); A002808(t1+1);
    fi; end;
    [seq(A121053(n),n=1..120)]; # N. J. A. Sloane, Nov 14 2024
  • Mathematica
    a[1]=2; a[2]=3; a[3]=5; a[4]=1; a[n_ /; PrimeQ[n] || !PrimeQ[n] && EvenQ[n+PrimePi[n]]] := Prime[Floor[(n+PrimePi[n])/2]]; a[n_ /; !PrimeQ[n] && OddQ[n+PrimePi[n]]] := If[!PrimeQ[n+1], n+1, n+2]; Table[a[n], {n, 1, 40}] (* Jean-François Alcover, Mar 21 2011, based on Dean Hickerson's formulas *)
  • Python
    from sympy import isprime, prime, primepi, composite, compositepi
    def a(n): return [2, 3, 5, 1, 7][n-1] if n < 6 else prime(n+primepi(n)>>1) if isprime(n) or (c:=compositepi(n))&1 else composite(c+1)
    print([a(n) for n in range(1, 81)]) # Michael S. Branicky, Nov 29 2024
    
  • Python
    # faster for initial segment of sequence
    from sympy import isprime, sieve
    from itertools import count, islice
    def nextcomposite(n): return next(k for k in count(n+1) if k not in sieve)
    def agen(): # generator of terms
        alst, chin, pin, nextc = [2, 3, 5, 1, 7], 1, 3, 6
        yield from alst
        for n in count(6):
            if isprimen:=n < nextc: pin += 1
            else: chin, nextc = chin + 1, nextcomposite(nextc)
            yield sieve[(n+pin)>>1] if isprimen or chin&1 else nextc
    print(list(islice(agen(), 80))) # Michael S. Branicky, Nov 29 2024

A099862 a(n) = (2*k)-th composite number; a bisection of A002808.

Original entry on oeis.org

6, 9, 12, 15, 18, 21, 24, 26, 28, 32, 34, 36, 39, 42, 45, 48, 50, 52, 55, 57, 60, 63, 65, 68, 70, 74, 76, 78, 81, 84, 86, 88, 91, 93, 95, 98, 100, 104, 106, 110, 112, 115, 117, 119, 121, 123, 125, 128, 130, 133, 135, 138, 141, 143, 145, 147, 150, 153, 155, 158, 160
Offset: 1

Views

Author

N. J. A. Sloane, Nov 19 2004

Keywords

Examples

			a(1) = 6 is the second composite number.
		

Crossrefs

Complement of A377898.

Programs

  • Maple
    c:=proc(n) if isprime(n) then else n fi end: B:=[seq(c(n),n=2..250)]: seq(B[2*m],m=1..75); # Emeric Deutsch, Dec 09 2004
  • Mathematica
    Partition[Select[Range[200], CompositeQ], 2][[All, 2]] (* Jean-François Alcover, Mar 22 2023 *)

Extensions

More terms from Emeric Deutsch, Dec 09 2004

A175228 Remaining sequence of step 3 of sieve from A175227.

Original entry on oeis.org

1, 4, 8, 10, 14, 16, 20, 22, 25, 27, 30, 33, 35, 38, 40, 44, 46, 49, 51, 54, 56, 58, 62, 64, 66, 69, 72, 75, 77, 80, 82, 85, 87, 90, 92, 94, 96, 99, 102
Offset: 1

Views

Author

Jaroslav Krizek, Mar 07 2010

Keywords

Comments

See A175227 for definition.

Crossrefs

Cf. A099861. [From R. J. Mathar, Mar 13 2010]

A377899 a(n) = number of composite numbers c_{2*k+1} <= n, where c_m = A002808(m) is the m-th composite number.

Original entry on oeis.org

0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 3, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7, 7, 8, 8, 9, 9, 9, 10, 10, 10, 11, 11, 12, 12, 12, 13, 13, 14, 14, 14, 14, 15, 15, 16, 16, 16, 17, 17, 18, 18, 18, 19, 19, 20, 20, 21, 21, 21, 21, 22, 22, 23, 23, 24, 24, 24, 25, 25, 25, 26, 26, 26, 27, 27, 28, 28, 28, 29, 29, 30, 30, 30, 31, 31, 32, 32, 32, 33, 33, 34, 34, 35, 35, 36, 36, 36, 37, 37, 37
Offset: 1

Views

Author

N. J. A. Sloane, Nov 14 2024

Keywords

Examples

			c_1 = 4 and c_3 = 8 are <= 9, so a(9) = 2.
		

Crossrefs

Programs

  • Python
    from sympy import primepi
    def A377899(n): return n-primepi(n)>>1 # Chai Wah Wu, Nov 14 2024

Formula

a(n) = floor((n-A000720(n))/2). - Chai Wah Wu, Nov 14 2024

A379054 a(n) = composite(2*n+2) - composite(2*n).

Original entry on oeis.org

3, 3, 3, 3, 3, 3, 2, 2, 4, 2, 2, 3, 3, 3, 3, 2, 2, 3, 2, 3, 3, 2, 3, 2, 4, 2, 2, 3, 3, 2, 2, 3, 2, 2, 3, 2, 4, 2, 4, 2, 3, 2, 2, 2, 2, 2, 3, 2, 3, 2, 3, 3, 2, 2, 2, 3, 3, 2, 3, 2, 2, 3, 3, 2, 2, 3, 2, 3, 3, 2, 2, 2, 3, 3, 3, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 3, 3, 3, 3
Offset: 1

Views

Author

N. J. A. Sloane, Dec 18 2024

Keywords

Comments

A121053 is divided into blocks, and (ignoring the initial terms of A121053) these are the lengths of the blocks.

Crossrefs

First differences of A099862.

Programs

  • Mathematica
    Differences[Select[Range[300], CompositeQ][[2 ;; ;; 2]]] (* Paolo Xausa, Dec 18 2024 *)

A379055 a(n) = composite(2*n+3) - composite(2*n+1).

Original entry on oeis.org

4, 2, 4, 2, 4, 2, 3, 2, 3, 3, 2, 3, 2, 4, 2, 3, 2, 3, 2, 2, 4, 2, 2, 3, 3, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 4, 2, 2, 2, 2, 4, 2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 4, 2, 2, 2, 2, 4, 2, 4, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 3, 2, 4, 2
Offset: 0

Views

Author

N. J. A. Sloane, Dec 18 2024

Keywords

Crossrefs

First differences of A099861.

Programs

  • Mathematica
    Differences[Select[Range[300], CompositeQ][[;; ;; 2]]] (* Paolo Xausa, Dec 18 2024 *)
Showing 1-6 of 6 results.