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

A121173 Sequence S with property that for n in S, a(n) = a(1) + a(2) +...+ a(n-1) and for n not in S, a(n) = n+1.

Original entry on oeis.org

2, 2, 4, 8, 6, 22, 8, 52, 10, 114, 12, 240, 14, 494, 16, 1004, 18, 2026, 20, 4072, 22, 8166, 24, 16356, 26, 32738, 28, 65504, 30, 131038, 32, 262108, 34, 524250, 36, 1048536, 38, 2097110, 40, 4194260, 42, 8388562, 44, 16777168, 46, 33554382
Offset: 1

Views

Author

Max Alekseyev, Aug 15 2006

Keywords

Comments

a(1)=1 cannot happen, so the sequence S starts with a(1)=2.
Note that a(n)=a(1)+a(2)+...+a(n-1) can hold even if n is not in S. The smallest example is n=3.
All terms are even. - Reinhard Zumkeller, Nov 06 2013

Crossrefs

Programs

  • Haskell
    a121173 n = a121173_list !! (n-1)
    a121173_list = f 1 [] where
       f x ys = y : f (x + 1) (y : ys) where
         y = if x `elem` ys then sum ys else x + 1
    -- Reinhard Zumkeller, Nov 06 2013
    
  • Mathematica
    s={2};Do[If[MemberQ[s,n],m=Total[s],m=n+1];AppendTo[s,m],{n,2,46}];s (* James C. McMahon, Oct 13 2024 *)
  • Python
    from itertools import count, islice
    def agen(): # generator of terms
        S, s, an = {2}, 2, 2
        for n in count(2):
            yield an
            an = s if n in S else n+1
            s += an
            S.add(an)
    print(list(islice(agen(), 50))) # Michael S. Branicky, Oct 13 2024

Formula

a(2*n) = A145654(n+1). - Reinhard Zumkeller, Nov 06 2013
a(2*n+1) = 2*n+2.
From Colin Barker, Jan 30 2016: (Start)
a(n) = 2*(2^(n/2+1)-2)-n for n even.
a(n) = n+1 for n odd.
a(n) = -a(n-1)+3*a(n-2)+3*a(n-3)-2*a(n-4)-2*a(n-5) for n>5.
G.f.: 2*x*(1+2*x) / ((1-x)*(1+x)^2*(1-2*x^2)). (End)
E.g.f.: (x - 4)*cosh(x) + 4*cosh(sqrt(2)*x) + (1 - x)*sinh(x). - Stefano Spezia, Oct 14 2024

A121174 Sequence S with property (making all terms distinct) that (i) a(1)=3, (ii) for n is S, a(n)=a(1)+a(2)+...+a(n-1), (iii) for n not in S, a(n)=the smallest number different from a(1), ..., a(n-1) not breaking condition (ii).

Original entry on oeis.org

3, 4, 7, 14, 6, 34, 68, 9, 145, 11, 301, 13, 615, 1230, 16, 2476, 18, 4970, 20, 9960, 22, 19942, 24, 39908, 26, 79842, 28, 159712, 30, 319454, 32, 638940, 35, 1277915, 2555830, 37, 5111697, 39, 10223433, 41, 20446907, 43, 40893857, 45
Offset: 1

Views

Author

Max Alekseyev, Aug 15 2006

Keywords

Crossrefs

A378030 Lexicographically earliest sequence of distinct positive integers such that a(a(n)) = a(a(n)-1) + a(a(n)-2).

Original entry on oeis.org

3, 4, 7, 11, 6, 17, 23, 9, 32, 12, 44, 56, 14, 70, 16, 86, 102, 19, 121, 21, 142, 24, 166, 190, 26, 216, 28, 244, 30, 274, 33, 307, 340, 35, 375, 37, 412, 39, 451, 41, 492, 43, 535, 578, 46, 624, 48, 672, 50, 722, 52, 774, 54, 828, 57, 885, 942, 59, 1001, 61, 1062, 63, 1125, 65, 1190, 67, 1257, 69, 1326, 1395, 72, 1467, 74, 1541, 76, 1617, 78, 1695, 80
Offset: 1

Views

Author

Scott R. Shannon, Nov 14 2024

Keywords

Comments

A self-referencing Fibonacci sequence. The terms appear to be concentrated along two lines, a lower straight line where a(n) is approximately n and an upper curved line where a(n) ~ n^2/4.
The missing numbers are 1, 2, 5, 8, 10, 13, 15, 18, 20, 22, 25, 27, 29, 31, ... .

Examples

			a(1) = 3 as a(3) = 7 and a(3-1) + a(3-2) = 4 + 3 = 7.
		

Crossrefs

A121175 Sequence S with the following properties: (i) a(1)=2; (ii) for n is S, a(n)=a(1)+a(2)+...+a(n-1); (iii) for n not in S, a(n)=the smallest number different from a(1), ..., a(n-1) not breaking property (ii).

Original entry on oeis.org

2, 2, 4, 8, 3, 7, 26, 52, 10, 114, 12, 240, 14, 494, 16, 1004, 18, 2026, 20, 4072, 22, 8166, 24, 16356, 27, 32739, 65478, 29, 130985, 31, 262001, 33, 524035, 35, 1048105, 37, 2096247, 39, 4192533, 41, 8385107, 43, 16770257, 45, 33540559
Offset: 1

Views

Author

Max Alekseyev, Aug 15 2006

Keywords

Comments

Taking a(1)=2 makes all terms distinct except for a(1)=a(2)=2

Crossrefs

A358793 Lexicographically earliest sequence of positive and unique integers such that 2*Sum_{k = 1..n} a(k) = Sum_{k = 1..n} a(a(k)) for n > 1 and a(1) = 1.

Original entry on oeis.org

1, 3, 7, 5, 10, 8, 14, 16, 11, 20, 22, 13, 26, 28, 17, 32, 34, 19, 38, 40, 23, 44, 46, 25, 50, 52, 29, 56, 58, 31, 62, 64, 35, 68, 70, 37, 74, 76, 41, 80, 82, 43, 86, 88, 47, 92, 94, 49, 98, 100, 53, 104, 106, 55, 110, 112, 59, 116, 118, 61, 122, 124, 65, 128
Offset: 1

Views

Author

Thomas Scheuerle, Dec 01 2022

Keywords

Comments

There is a second version of this sequence possible if we change the definition to a(1) = 2 and a(n) > 1, then the sequence will start 2, 4, 5, 8, 10, 7, 14, ... . It will after this continue in the same way as our actual sequence does (and would also extend the valid range of the recurrence formulas).
Start a(1) = 2 and value 1 allowed is A257794.

Crossrefs

Programs

  • Mathematica
    LinearRecurrence[{0, 0, 1, 0, 0, 1, 0, 0, -1}, {1, 3, 7, 5, 10, 8, 14, 16, 11, 20, 22, 13, 26, 28, 17}, 100] (* Paolo Xausa, Jan 23 2025 *)
  • PARI
    a(n) = {my(v = [1, 3, 7, 5, 10, 8]);if(n < 7, v[n], n*(1+min(1, n%3))+(n%3 == 0)+(n%6 == 3))}

Formula

G.f.: x*(1 + 3*x + 7*x^2 + 4*x^3 + 7*x^4 + x^5 + 8*x^6 + 3*x^7 - 4*x^8 + 2*x^9 - x^10 + x^11 - 3*x^12 + x^14)/(1 - x^3 - x^6 + x^9).
a(n) = a(n-3) + a(n-6) - a(n-9) for n >= 16.
a((3*(2*n-1) - (-1)^n)/4) = (3*(2*n-1) - (-1)^n)/2, for n > 3.
a(6*n) = 6*n+1, for n > 1.
a(6*n+3) = 6*n+5, for n > 0.
a(n) = 30*n - 2*a(n-1) - 3*a(n-2) - 3*a(n-3) - 3*a(n-4) - 3*a(n-5) - 2*a(n-6) - a(n-7) - 96, for n > 13.
Showing 1-6 of 6 results.