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.

A077390 Primes which leave primes at every step if most significant digit and least significant digit are deleted until a one digit or two digit prime is obtained.

Original entry on oeis.org

2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 127, 131, 137, 139, 151, 157, 173, 179, 223, 227, 229, 233, 239, 251, 257, 271, 277, 331, 337, 353, 359, 373, 379, 421, 431, 433, 439, 457, 479, 521, 523, 557, 571, 577, 631, 653, 659
Offset: 1

Views

Author

Amarnath Murthy, Nov 07 2002

Keywords

Comments

There are exactly 920720315 such primes, the largest being 9161759674286961988443272139114537477768682563429152377117139 1111313737919133977331737137933773713713973. - Karl W. Heuer, Apr 19 2011
There are exactly 331780864 odd length primes and 588939451 even length primes, the largest odd length prime being
7228828176786792552781668926755667258635743361825711373791931117197999133917737137399993737111177. - Seth A. Troisi, May 07 2019
Zeros are not permitted, otherwise this sequence would potentially be infinite (cf. A077391). - Sean A. Irvine, May 19 2025

Examples

			21313 is a member as 21313, 131 and 3 all are primes.
		

Crossrefs

Cf. A024770 (right-truncatable primes), A024785 (left-truncatable primes), A137812 (left-or-right truncatable primes).
Cf. A077391.

Programs

  • Mathematica
    msd={1,2,3,4,5,6,7,8,9}; lsd={1,3,7,9}; Clear[p]; p[1]={2,3,5,7}; p[2]={11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97}; p[digits_] := p[digits] = Select[Flatten[Outer[Plus, 10^(digits-1)*msd, 10*p[digits-2], lsd]], PrimeQ]; t={}; k=0; While[Length[t] < 100, k++; t=Join[t, p[k]]]; t (* T. D. Noe, Apr 19 2011 *)
    paesQ[n_]:=AllTrue[NestWhileList[FromDigits[Most[Rest[ IntegerDigits[ #]]]]&, n,#>99&],PrimeQ]; Select[Prime[Range[150]],paesQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Feb 01 2015 *)
  • Python
    from itertools import count, islice
    from sympy import isprime, primerange
    def agen(): # generator of terms
        odds, evens, digits = [2, 3, 5, 7], list(primerange(10, 100)), 3
        yield from odds + evens
        while len(odds) > 0 or len(evens) > 0:
            new = []
            old = odds if digits%2 == 1 else evens
            for first in "123456789":
                for p in old:
                    mid = str(p)
                    for last in "1379":
                        t = int(first + mid + last)
                        if isprime(t):
                            yield t
                            new.append(t)
            old = new
            if digits%2: odds = old
            else: evens = old
            print("...", digits, time()-time0)
            digits += 1
    print(list(islice(agen(), 80))) # Michael S. Branicky, May 06 2022

Extensions

Corrected and extended by T. D. Noe, Apr 19 2011