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.

User: Timothy Smith

Timothy Smith's wiki page.

Timothy Smith has authored 2 sequences.

A347864 Left- or right-truncatable primes, restricted to one consecutive zero.

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 23, 29, 31, 37, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97, 103, 107, 113, 131, 137, 139, 167, 173, 179, 197, 223, 229, 233, 239, 271, 283, 293, 307, 311, 313, 317, 331, 337, 347, 353, 359, 367, 373, 379, 383, 397, 431, 433, 439, 443, 467, 479, 503
Offset: 1

Author

Timothy Smith, Jan 25 2022

Keywords

Comments

There are 16484138 primes in this list, in total. The largest one has 60 digits and there is only one of that length.

Crossrefs

Left- or right-truncatable primes, excluding all 0s: A137812.
The number of primes of length n following these rules: A346662.

Programs

  • Python
    from sympy import isprime
    route = set({})
    nums = [i*(10**j) for i in range(1, 10) for j in range(2)]
    def addnum(a):
        global route
        for j in nums:
            b = int("{}{}".format(a, j))
            if isprime(b):
                if b not in route:
                    route.add(b)
                    addnum(b)
        for j in nums:
            b = int("{}{}".format(j, a))
            if isprime(b):
                if b not in route:
                    route.add(b)
                    addnum(b)
    def run():
        for i in nums:
            if isprime(i):
                addnum(i)

A346662 Number of n-digit left- or right-truncatable primes with no consecutive zero digits.

Original entry on oeis.org

4, 16, 76, 300, 955, 2648, 6402, 14339, 28684, 53450, 91284, 147064, 221301, 319067, 433227, 567565, 700765, 834464, 947055, 1050886, 1114368, 1157526, 1150645, 1117265, 1044757, 963722, 855804, 753172, 633786, 528122, 426328, 339866, 264078, 202013, 150330, 111055, 78996, 56123, 38874, 26644, 17944, 11898, 7878, 4945, 3255, 2024, 1323, 764, 464, 286, 158, 77, 40, 26, 14, 5, 5, 4, 1, 1
Offset: 1

Author

Timothy Smith, Jan 25 2022

Keywords

Comments

A left- or right-truncatable prime is a prime number from which one digit at a time may be removed from the left or right end until a single-digit prime is reached, with each digit removal resulting in a prime. There exists only one such 60-digit prime: 202075909708030901050930450609080660821035604908735717137397. Since it cannot be extended, there are no such primes with more than 60 digits, so a(60)=1 is the final term of the sequence.

Examples

			The 16 two-digit left- or right-truncatable primes with no consecutive zero digits are 13, 17, 23, 29, 31, 37, 43, 47, 53, 59, 67, 71, 73, 79, 83, 97.
The first 10 three-digit left- or right-truncatable primes with no consecutive zero digits are 103, 107, 113, 131, 137, 139, 167, 173, 179, 197.
The unique 60-digit left- or right-truncatable prime with no consecutive zero digits can be sequentially truncated to a single-digit prime as follows, where each "..." indicates repeated removal of the leftmost digit:
    202075909708030901050930450609080660821035604908735717137397
    ...
      2075909708030901050930450609080660821035604908735717137397
      207590970803090105093045060908066082103560490873571713739
      ...
            970803090105093045060908066082103560490873571713739
            97080309010509304506090806608210356049087357171373
            ...
                               6090806608210356049087357171373
                               609080660821035604908735717137
                               ...
                                   80660821035604908735717137
                                   8066082103560490873571713
                                   806608210356049087357171
                                   ...
                                        8210356049087357171
                                        821035604908735717
                                         21035604908735717
                                         2103560490873571
                                         ...
                                                       71
                                                       7
		

Crossrefs

Left- or right-truncatable primes, excluding all 0s: A137812.
Left- or right-truncatable primes with 0s allowed, but none consecutive: A347864.

Programs

  • Python
    from sympy import isprime
    dumps = set({})
    route = set({})
    nums = [i*(10**j) for i in range(1, 10) for j in range(2)]
    def addnum(a):
        global route
        for j in nums:
            b = int("{}{}".format(a, j))
            if isprime(b):
                if b not in route:
                    route.add(b)
                    addnum(b)
        for j in nums:
            b = int("{}{}".format(j, a))
            if isprime(b):
                if b not in route:
                    route.add(b)
                    addnum(b)
    def run():
        for i in nums:
            if isprime(i):
                addnum(i)
    run()