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

A232126 First element of the chain of primes ending in A232125(n), prime which cannot be extended to another prime by appending a digit, as it is the case of the other elements of the chain.

Original entry on oeis.org

53, 5, 3, 2, 2, 3, 2, 2, 19, 103, 409, 1457011
Offset: 0

Views

Author

Michel Marcus and M. F. Hasler, Nov 19 2013

Keywords

Comments

See sequence A231426 for a variant using a similar concept "working forwards", i.e., the longest possible extension is looked for. See also A232127, A232128.

Examples

			a(0)=53 is the least prime that cannot be extended to another prime by appending some digit.
a(1)=5 is the least prime that can be extended ("once") to another prime, by appending the digit "3", such that the new prime cannot be extended further. (Indeed, 2 can be extended to 23 or 29, and 3 can be extended to 31 and 37, but all these allow at least one further extension to some prime, e.g., 233, 293, 311 and 373.)
a(3) = 2 is the first prime in the chain (2, 23, 239, 2393) where a digit is added 3 times to yield another prime, while adding any digit to the last term will give a composite. Here, 2393 is the least prime to occur in such a sequence of length 4=1+3.
		

Formula

a(n) = A232125(n)/10^n.

A232127 Maximal number of digits that can be appended to prime(n) preserving primality at each step.

Original entry on oeis.org

7, 7, 7, 7, 1, 6, 3, 8, 6, 6, 3, 6, 1, 5, 3, 0, 6, 5, 5, 4, 6, 1, 1, 0, 2, 4, 9, 0, 4, 0, 5, 1, 1, 5, 3, 1, 2, 1, 0, 2, 0, 4, 2, 3, 7, 5, 2, 3, 4, 3, 5, 4, 5, 0, 4, 3, 4, 5, 3, 1, 1, 5, 1, 2, 2, 0, 6, 3, 0, 4, 5, 2, 4, 5, 1, 2, 0, 0, 3, 10, 0, 3, 0, 2, 4, 0, 3, 0, 0, 6
Offset: 1

Views

Author

M. F. Hasler and Michel Marcus, Nov 19 2013

Keywords

Comments

Consider chains (p^(0),p^(1),p^(2),...p^(L)) of primes such that p^(k-1) = floor(p^(k)/10), or otherwise said, p^(k+1) is obtained from p^(k) by appending a digit. Then a(n) is one less than the number of primes in the longest possible such chain with p^(0)=prime(n).

Examples

			a(14)=5 because for prime(14)=43, one can add at most 5 digits to the right preserving primality at each step: 439 is prime, 4391 is prime, 43913 is prime, 439133 is prime, 4391339 is prime. There is no longer chain possible starting with 43.
		

Crossrefs

Cf. A232125.

Programs

  • PARI
    {howfar(p)=my(m);forstep(d=1,9,2,d==5&&next;isprime(p*10+d)||next;m=max(1+howfar(10*p+d),m));m}
    
  • Python
    from sympy import isprime, prime
    def a(n):
      pn = prime(n); ftr = {pn}; ext = 0
      while len(ftr) > 0:
        r1 = set(filter(isprime, (int(str(e)+d) for d in "1379" for e in ftr)))
        ext, ftr = ext+1, r1
      return ext - 1
    print([a(n) for n in range(1, 91)]) # Michael S. Branicky, Jul 07 2021
    
  • Python
    # faster version for initial segment of sequence
    from sympy import isprime, prime, primerange
    def aupton(terms):
      alst = []
      for p in primerange(1, prime(terms)+1):
        r = {p}; e = 0
        while len(r) > 0:
          r1 = set(filter(isprime, (int(str(e)+d) for d in "1379" for e in r)))
          e, r = e+1, r1
        alst.append(e - 1)
      return alst
    print(aupton(90)) # Michael S. Branicky, Jul 07 2021

Formula

a(n)=A232128(A000040(n)).
a(n) > 0 if and only if there is a prime p between 10*prime(n)+1 and 10*prime(n)+9, in which case a(n) >= 1+a(primepi(p))
a(n) = max { L in N | exists (p[0],...,p[L]) in P^(L+1) (P = the primes A000040), such that p[0] = prime(n) and for k=1,...,L : p[k-1] = floor(p[k]/10) }

A232128 Maximal number of digits that can be appended to n such that each step yields a prime.

Original entry on oeis.org

9, 7, 7, 6, 7, 6, 7, 2, 3, 10, 1, 6, 6, 4, 3, 2, 3, 5, 8, 0, 3, 5, 6, 6, 5, 5, 6, 2, 6, 2, 3, 0, 7, 5, 6, 5, 6, 3, 1, 11, 1, 4, 5, 4, 1, 7, 3, 4, 6, 4, 0, 5, 0, 6, 4, 4, 6, 2, 6, 7, 5, 0, 4, 2, 3, 3, 5, 2, 5, 4, 4, 1, 6, 2, 4, 4, 1, 7, 1, 4, 4, 10, 1, 0, 5, 1, 6, 5, 0, 1, 4
Offset: 1

Views

Author

M. F. Hasler, Nov 19 2013

Keywords

Comments

The digits are to be appended one by one as to form a chain of L = a(n) primes [p^(1),...,p^(L)], such that p^(k-1)=floor(p^(k)/10), k=1,...,L, starting from the initial value p^(0) = n which is not required to be a prime. (See A232127 for the variant restricted to prime "starting values".)
See A232129 for the largest prime obtained when starting with n.

Examples

			a(1)=9 because "1" can be extended with at most 9 digits to the right such that each extension is prime; the least one of the possible 1+9 digit primes is 1979339333, the largest one is given in A232129.
		

Crossrefs

Programs

  • Maple
    f:= proc(n) local V,k;
          V:= select(isprime, [seq(10*n+k, k=[1,3,7,9])]);
          if V = [] then 0 else 1 + max(map(procname,V)) fi
    end proc:
    map(f, [$1..100]); # Robert Israel, Oct 16 2020
  • PARI
    a(n)=my(m,r=[0,n]);forstep(d=1,9,2,d==5&&next;isprime(n*10+d)||next;m=[1,0]+howfar(10*n+d);m[1]>r[1]&&r=m);r \\ Note: this returns the list [a(n), minimal longest prime]
    
  • Python
    from sympy import isprime, nextprime
    def a(n):
        while True:
            extends, reach, maxp = -1, {n}, 0
            while len(reach) > 0:
                candidates = (int(str(e)+d) for d in "1379" for e in reach)
                reach1 = set(filter(isprime, candidates))
                extends, reach, maxp = extends+1, reach1, max({maxp}|reach1)
            return extends
    print([a(n) for n in range(1, 92)]) # Michael S. Branicky, Sep 07 2021

Formula

If a(n) > 0, then there is some prime p in the range 10n+1,...,10n+9 such that a(p)=a(n)-1. If a(n)=0, then there is no prime in that range.

A232129 Largest prime that can be obtained from n by successively appending digits to the right with the constraint that each of the numbers obtained that way must be prime; a(n)=0 if there is no such prime at all.

Original entry on oeis.org

1979339339, 29399999, 37337999, 4391339, 59393339, 6733997, 73939133, 839, 9719, 103997939939, 113, 12791333, 13999133, 149399, 15797, 1637, 17333, 1811993, 1979339339, 0, 21139, 2273993, 23399339, 24179399, 2579939, 2699393, 27191939, 2837, 29399999, 3079, 31379, 0, 331999799, 3491333, 35393999
Offset: 1

Views

Author

M. F. Hasler, Nov 19 2013

Keywords

Comments

See A232128 for the number of steps required to reach a(n), equal to the length of a(n) minus the length of n. See A232126 for a variant "working backwards", where truncation is considered.

Examples

			Starting with 8, one can get the primes 83 and 89 which is larger, but 83 allows one further extension to 839 while 89 does not (no prime in the range 890..899). No further extension is possible, since there are no primes in the range 8390,...,8399. Therefore a(8)=839 and A232128(8)=2.
a(20)=a(42)=0 since no prime can be obtained by appending one digit to 20 or 42.
		

Crossrefs

Programs

  • PARI
    {A232129(n)=local(t(p)=my(m,r=[0,p]);forstep(d=1,9,2,isprime(p*10+d)&&(m=t(10*p+d)+[1,0])[1]>=r[1]&&r=m);r);n<(n=t(n))[2]&&return(n[2])}
    
  • Python
    from sympy import isprime, nextprime
    def a(n):
        while True:
            extends, reach, maxp = -1, {n}, 0
            while len(reach) > 0:
                candidates = (int(str(e)+d) for d in "1379" for e in reach)
                reach1 = set(filter(isprime, candidates))
                extends, reach, maxp = extends+1, reach1, max({maxp}|reach1)
            return maxp
    print([a(n) for n in range(1, 36)]) # Michael S. Branicky, Sep 07 2021

A231426 Least prime such that at most n digits may be appended to the right, preserving primality at each step.

Original entry on oeis.org

53, 11, 97, 17, 71, 43, 13, 2, 19, 103, 409, 1457011, 2744903797, 5232781111
Offset: 0

Views

Author

Michel Marcus and M. F. Hasler, Nov 19 2013

Keywords

Examples

			a(7) = 2 is the least prime which starts several sequences of 1+7 primes, e.g., (2, 23, 239, 2393, ..., 23399339) and others leading at most to 29399999 = A232129(2), where a digit is appended 7 times to yield a prime after each step, while it is not possible in any of the "branches" to append one more digit to the last term, preserving primality.
		

Crossrefs

Programs

  • Python
    from sympy import isprime, nextprime
    def a(n):
        p = 2
        while True:
            extends, reach = -1, {p}
            while len(reach) > 0:
                candidates = (int(str(e)+d) for d in "1379" for e in reach)
                reach1 = set(filter(isprime, candidates))
                extends, reach = extends + 1, reach1
            if extends == n: return p
            p = nextprime(p)
    for n in range(12): print(a(n), end=", ") # Michael S. Branicky, Aug 15 2021

Formula

a(n) is the least prime p=prime(k) such that A232128(p) (= A232127(k)) = n.
If a(n) = p, then a(n) = floor(A232129(p)/10^A232128(p)).
A232125(n) <= (a(n)+1)*10^n - 1. - Michael S. Branicky, Aug 15 2021

Extensions

a(12)-a(13) from Michael S. Branicky, Aug 15 2021
Showing 1-5 of 5 results.