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

A137812 Left- or right-truncatable primes.

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, 113, 131, 137, 139, 167, 173, 179, 197, 223, 229, 233, 239, 271, 283, 293, 311, 313, 317, 331, 337, 347, 353, 359, 367, 373, 379, 383, 397, 431, 433, 439, 443, 467, 479, 523, 547, 571
Offset: 1

Views

Author

T. D. Noe, Feb 11 2008

Keywords

Comments

Repeatedly removing a digit from either the left or right produces only primes. There are 149677 terms in this sequence, ending with 8939662423123592347173339993799.
The number of n-digit terms is A298048(n). - Jon E. Schoenfield, Jan 28 2022

Examples

			139 is here because (removing 9 from the right) 13 is prime and (removing 1 from the left) 3 is prime.
		

Crossrefs

Cf. A024770 (right-truncatable primes), A024785 (left-truncatable primes), A077390 (left-and-right truncatable primes), A080608.
Cf. A298048 (number of n-digit terms).

Programs

  • Mathematica
    Clear[s]; s[0]={2,3,5,7}; n=1; While[s[n]={}; Do[k=s[n-1][[i]]; Do[p=j*10^n+k; If[PrimeQ[p], AppendTo[s[n],p]], {j,9}]; Do[p=10*k+j; If[PrimeQ[p], AppendTo[s[n],p]], {j,9}], {i,Length[s[n-1]]}]; s[n]=Union[s[n]]; Length[s[n]]>0, n++ ];t=s[0]; Do[t=Join[t,s[i]], {i,n}]; t
  • Python
    from sympy import isprime
    def agen():
        primes = [2, 3, 5, 7]
        while len(primes) > 0:
            yield from primes
            cands = set(int(d+str(p)) for p in primes for d in "123456789")
            cands |= set(int(str(p)+d) for p in primes for d in "1379")
            primes = sorted(c for c in cands if isprime(c))
    afull = [an for an in agen()]
    print(afull[:60]) # Michael S. Branicky, Aug 04 2022

A297960 a(1) = number of 1-digit primes (that is, 4: 2,3,5,7); then a(n) = number of distinct n-digit prime numbers obtained by alternately right- and left-concatenating a digit to the a(n-1) primes obtained in the previous iteration.

Original entry on oeis.org

4, 9, 30, 49, 99, 74, 101, 71, 72, 35, 28, 9, 4
Offset: 1

Views

Author

Seiichi Manyama, Jan 09 2018

Keywords

Comments

No 14-digit numbers can be obtained from the four 13-digit numbers counted by a(13).

Examples

			1-digit   2-digit   3-digit    4-digit   ...  13-digit
------------------------------------------------------------
2         23        223        2237
                               2239
                    523        5231
                               5233
                               5237
                    823        8231
                               8233            6638182333331
                               8237
          29        229        2293
                               2297
                    829        8291
                               8293
                               8297
                    929        9293
3         31        131        1319
                    331        3313
                               3319
                    431
                    631        6311            5981563119937
                               6317
          37        137        1373
                    337        3371
                               3373
                    937        9371
                               9377
5         53        353        3533
                               3539
                    653
                    853        8537
                               8539
                    953        9533
                               9539
          59        359        3593
                    659        6599
                    859        8597
                               8599
7         71        271        2711
                               2713
                               2719
                    571        5711
                               5717
                    971        9719
          73        173        1733
                    373        3733
                               3739
                    673        6733            8313667333393
                               6737
                    773
          79        179
                    379        3793            2682637937713
                               3797
                    479        4793
                               4799
------------------------------------------------------------
a(1) = 4, a(2) = 9, a(3) = 30, a(4) = 49, ..., a(13) = 4.
		

Crossrefs

Programs

  • Mathematica
    Block[{b = 10, t}, t = Select[Range[b], CoprimeQ[#, b] &]; TakeWhile[Length /@ Fold[Function[{a, n}, Append[a, If[OddQ[n], Join @@ Map[Function[k, Select[Map[Prepend[k, #] &, Range[9]], PrimeQ@ FromDigits[#, b] &]], Last[a]], Join @@ Map[Function[k, Select[Map[Append[k, #] &, t], PrimeQ@ FromDigits[#, b] &]], Last[a]]]]] @@ {#1, #2} &, {IntegerDigits[Prime@ Range@ PrimePi@b, b]}, Range[2, 16]], # > 0 &]] (* Michael De Vlieger, Jan 20 2018 *)
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], []
      while len(primes) > 0:
        alst.append(len(primes))
        if len(alst)%2 == 0:
          candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        else:
          candidates = set(int(str(p)+d) for p in primes for d in "1379")
        primes = [c for c in candidates if isprime(c)]
      return alst
    print(alst()) # Michael S. Branicky, Apr 11 2021

A297961 a(1) = number of 1-digit primes (that is, 4: 2,3,5,7); then a(n) = number of distinct n-digit prime numbers obtained by alternately left- and right-concatenating a digit to the a(n-1) primes obtained in the previous iteration.

Original entry on oeis.org

4, 11, 20, 53, 51, 100, 63, 76, 42, 43, 20, 13, 4, 4, 1
Offset: 1

Views

Author

Seiichi Manyama, Jan 09 2018

Keywords

Comments

No 16-digit numbers can be obtained from the 15-digit number 889292677731979.

Examples

			1-digit   2-digit    3-digit    4-digit   ...  15-digit
---------------------------------------------------------------
2
3         13         131        2131
                                6131
                     137        2137
                                3137
                                9137
                     139        4139
          23         233        5233
                                8233
                     239        2239
                                9239
          43         431        5431
                                8431
                                9431
                     433        1433
                                3433
                                7433
                                9433
                     439        1439
                                9439
          53
          73         733        1733
                                3733
                                4733
                                6733
                                9733
                     739        3739
                                9739
          83         839        5839
                                8839
                                9839
5
7         17         173        6173
                                9173
                     179        2179
                                5179
                                8179
          37         373        1373
                                3373
                                4373
                                6373
                     379        6379
          47         479        5479
                                9479
          67         673        3673
                                4673
                                6673
                                7673
                     677        2677            889292677731979
                                3677
                                8677
                                9677
          97         971        2971
                                6971
                                8971
                     977        6977
---------------------------------------------------------------
a(1) = 4, a(2) = 11, a(3) = 20, a(4) = 53, ..., a(15)= 1.
		

Crossrefs

Programs

  • Mathematica
    Block[{b = 10, t}, t = Select[Range[b], CoprimeQ[#, b] &]; TakeWhile[Length /@ Fold[Function[{a, n}, Append[a, If[EvenQ[n], Join @@ Map[Function[k, Select[Map[Prepend[k, #] &, Range[9]], PrimeQ@ FromDigits[#, b] &]], Last[a]], Join @@ Map[Function[k, Select[Map[Append[k, #] &, t], PrimeQ@ FromDigits[#, b] &]], Last[a]]]]] @@ {#1, #2} &, {IntegerDigits[Prime@ Range@ PrimePi@ b, b]}, Range[2, 16]], # > 0 &]] (* Michael De Vlieger, Jan 20 2018 *)
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], []
      while len(primes) > 0:
        alst.append(len(primes))
        if len(alst)%2 == 1:
          candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        else:
          candidates = set(int(str(p)+d) for p in primes for d in "1379")
        primes = [c for c in candidates if isprime(c)]
      return alst
    print(alst()) # Michael S. Branicky, Apr 11 2021
Showing 1-3 of 3 results.