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

A024770 Right-truncatable primes: every prefix is prime.

Original entry on oeis.org

2, 3, 5, 7, 23, 29, 31, 37, 53, 59, 71, 73, 79, 233, 239, 293, 311, 313, 317, 373, 379, 593, 599, 719, 733, 739, 797, 2333, 2339, 2393, 2399, 2939, 3119, 3137, 3733, 3739, 3793, 3797, 5939, 7193, 7331, 7333, 7393, 23333, 23339, 23399, 23993, 29399, 31193
Offset: 1

Views

Author

Keywords

Comments

Primes in which repeatedly deleting the least significant digit gives a prime at every step until a single-digit prime remains. The sequence ends at a(83) = 73939133 = A023107(10).
The subsequence which consists of the following "chain" of consecutive right truncatable primes: 73939133, 7393913, 739391, 73939, 7393, 739, 73, 7 yields the largest sum, compared with other chains formed from subsets of this sequence: 73939133 + 7393913 + 739391 + 73939 + 7393 + 739 + 73 + 7 = 82154588. - Alexander R. Povolotsky, Jan 22 2008
Can also be seen as a table whose n-th row lists the n-digit terms; row lengths (0 for n >= 9) are given by A050986. The sequence can be constructed starting with the single-digit primes and appending, for each p in the list, the primes within 10*p and 10(p+1), formed by appending a digit to p. - M. F. Hasler, Nov 07 2018

References

  • Roozbeh Hazrat, Mathematica: A Problem-Centered Approach, Springer London 2010, pp. 86-89.
  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, pages 112-113.

Crossrefs

Supersequence of A085823, A202263. Subsequence of A012883, A068669. - Jaroslav Krizek, Jan 28 2012
Supersequence of A239747.
Cf. A033664, A024785 (left-truncatable primes), A032437, A020994, A052023, A052024, A052025, A050986, A050987, A069866, A077390 (left-and-right-truncatable primes), A137812 (left-or-right truncatable primes), A254751, A254753.
Cf. A237600 for the base-16 analog.

Programs

  • Haskell
    import Data.List (inits)
    a024770 n = a024770_list !! (n-1)
    a024770_list = filter (\x ->
       all (== 1) $ map (a010051 . read) $ tail $ inits $ show x) a038618_list
    -- Reinhard Zumkeller, Nov 01 2011
    
  • Maple
    s:=[1,3,7,9]: a:=[[2],[3],[5],[7]]: l1:=1: l2:=4: do for j from l1 to l2 do for k from 1 to 4 do d:=[s[k],op(a[j])]: if(isprime(op(convert(d, base, 10, 10^nops(d)))))then a:=[op(a), d]: fi: od: od: l1:=l2+1: l2:=nops(a): if(l1>l2)then break: fi: od: seq(op(convert(a[j], base, 10, 10^nops(a[j]))),j=1..nops(a)); # Nathaniel Johnston, Jun 21 2011
  • Mathematica
    max = 100000; truncate[p_] := If[PrimeQ[q = Quotient[p, 10]], q, p]; ok[p_] := FixedPoint[ truncate, p] < 10; p = 1; A024770 = {}; While[ (p = NextPrime[p]) < max, If[ok[p], AppendTo[ A024770, p]]]; A024770 (* Jean-François Alcover, Nov 09 2011, after Pari *)
    eppQ[n_]:=AllTrue[FromDigits/@Table[Take[IntegerDigits[n],i],{i, IntegerLength[ n]-1}], PrimeQ]; Select[Prime[Range[3400]],eppQ] (* The program uses the AllTrue function from Mathematica version 10 *) (* Harvey P. Dale, Jan 14 2015 *)
  • PARI
    {fileO="b024770.txt";v=vector(100);v[1]=2;v[2]=3;v[3]=5;v[4]=7;j=4;j1=1; write(fileO,"1 2");write(fileO,"2 3");write(fileO,"3 5");write(fileO,"4 7"); until(0,if(j1>j,break);new=1;for(i=j1,j,if(new,j1=j+1;new=0);for(k=1,9, z=10*v[i]+k;if(isprime(z),j++;v[j]=z;write(fileO,j," ",z);))));} \\ Harry J. Smith, Sep 20 2008
    
  • PARI
    for(n=2, 31193, v=n; while(isprime(n), c=n; n=(c-lift(Mod(c, 10)))/10); if(n==0, print1(v, ", ")); n=v); \\ Arkadiusz Wesolowski, Mar 20 2014
    
  • PARI
    A024770=vector(9, n, p=concat(apply(t->primes([t, t+1]*10), if(n>1, p)))) \\ The list of n-digit terms, 1 <= n <= 9. Use concat(%) to "flatten" it. - M. F. Hasler, Nov 07 2018
    
  • Python
    from sympy import primerange
    p = lambda x: list(primerange(x, x+10)); A024770 = p(0); i=0
    while iA024770): A024770+=p(A024770[i]*10); i+=1 # M. F. Hasler, Mar 11 2020

A024785 Left-truncatable primes: every suffix is prime and no digits are zero.

Original entry on oeis.org

2, 3, 5, 7, 13, 17, 23, 37, 43, 47, 53, 67, 73, 83, 97, 113, 137, 167, 173, 197, 223, 283, 313, 317, 337, 347, 353, 367, 373, 383, 397, 443, 467, 523, 547, 613, 617, 643, 647, 653, 673, 683, 743, 773, 797, 823, 853, 883, 937, 947, 953, 967, 983, 997, 1223
Offset: 1

Views

Author

Keywords

Comments

Last term is a(4260) = 357686312646216567629137 (Angell and Godwin). - Eric W. Weisstein, Dec 11 1999
Can be seen as table whose rows list n-digit terms, 1 <= n <= 25. Row lengths are A050987. - M. F. Hasler, Nov 07 2018

References

  • James J. Tattersall, Elementary Number Theory in Nine Chapters, Cambridge University Press, 1999, page 113.

Crossrefs

Supersequence of A240768.
Cf. A033664, A032437, A020994, A024770 (right-truncatable primes), A052023, A052024, A052025, A050986, A050987, A077390 (left-and-right truncatable primes), A137812 (left-or-right truncatable primes), A254753.

Programs

  • Haskell
    import Data.List (tails)
    a024785 n = a024785_list !! (n-1)
    a024785_list = filter (\x ->
       all (== 1) $ map (a010051 . read) $ init $ tails $ show x) a038618_list
    -- Reinhard Zumkeller, Nov 01 2011
    
  • Maple
    a:=[[2],[3],[5],[7]]: l1:=1: l2:=4: for n from 1 to 3 do for k from 1 to 9 do for j from l1 to l2 do d:=[op(a[j]),k]: if(isprime(op(convert(d,base,10,10^nops(d)))))then a:=[op(a), d]: fi: od: od: l1:=l2+1: l2:=nops(a): if(l1>l2)then break: fi: od: seq(op(convert(a[j],base,10,10^nops(a[j]))),j=1..nops(a)); # Nathaniel Johnston, Jun 21 2011
    # second Maple program:
    T:= proc(n) option remember; `if`(n=0, "", sort(select(isprime,
          map(x-> seq(parse(cat(j, x)), j=1..9), [T(n-1)])))[])
        end:
    seq(T(n), n=1..4);  # Alois P. Heinz, Sep 01 2021
  • Mathematica
    max = 2000; truncate[p_] := If[id = IntegerDigits[p]; FreeQ[id, 0] && (Last[id] == 3 || Last[id] == 7) && PrimeQ[q = FromDigits[ Rest[id]]], q, p]; ok[n_] := FixedPoint[ truncate, n] < 10;p = 5; A024785 = {2, 3, 5}; While[(p = NextPrime[p]) < max, If[ok[p], AppendTo[A024785, p]]]; A024785 (* Jean-François Alcover, Nov 09 2011 *)
    d[n_]:=IntegerDigits[n]; ltrQ[n_]:=And@@PrimeQ[NestList[FromDigits[Drop[d[#],1]]&,n,Length[d[n]]-1]]; Select[Range[1225],ltrQ[#]&] (* Jayanta Basu, May 29 2013 *)
    FullList=Sort[Flatten[Table[FixedPointList[Select[Flatten[Table[Range[9]*10^Length@IntegerDigits[#[[1]]] + #[[i]], {i, Length[#]}]], PrimeQ] &, {i}], {i, {2, 3, 5, 7}}]]] (* Fabrice Laussy, Nov 10 2019 *)
  • PARI
    v=vector(4260);v[1]=2;v[2]=3;v[3]=5;v[4]=7;i=0;j=4; until(i>=j,i++;p=v[i];P10=10^(1+log(p)\log(10)); for(k=1,9,z=k*P10+p;if(isprime(z),j++;v[j]=z;))); s=vector(4260);s=vecsort(v);for(i=1,j,write("b024785.txt",i," ",s[i]);); \\
    
  • PARI
    is_A024785(n,t=1)={until(t>10*p,isprime(p=n%t*=10)||return);n==p} \\ M. F. Hasler, Apr 17 2014
    
  • PARI
    A024785=vector(25,n,p=vecsort(concat(apply(p->select(isprime, vector(9,i, i*10^(n-1)+p)),if(n>1,p))))); \\ Yields the list of rows (n-digit terms, n = 1..25). Use concat(%) to flatten. There are faster variants using matrices (vectorv(9,i,1)*p+[1..9]~*10^(n-1)*vector(#p,i,1)) and/or predefined vectors, but they are less concise and this takes less than 0.1 sec. - M. F. Hasler, Nov 07 2018
    
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], []
      while len(primes) > 0:
        alst += sorted(primes)
        candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        primes = [c for c in candidates if isprime(c)]
      return alst
    print(alst()) # Michael S. Branicky, Apr 11 2021

A227916 Primes that remain prime when the leftmost digit is removed.

Original entry on oeis.org

13, 17, 23, 37, 43, 47, 53, 67, 73, 83, 97, 103, 107, 113, 131, 137, 167, 173, 179, 197, 211, 223, 229, 241, 271, 283, 307, 311, 313, 317, 331, 337, 347, 353, 359, 367, 373, 379, 383, 389, 397, 419, 431, 443, 461, 467, 479, 503, 523, 541, 547, 571, 607, 613, 617
Offset: 1

Views

Author

K. D. Bajpai, Oct 13 2013

Keywords

Examples

			a(11)= 97 which is prime. Removing the leftmost digit gives 7, also prime.
a(28)= 311 which is prime. Removing the leftmost digit gives 11, also prime.
		

Crossrefs

Cf. A000040 (prime numbers), A024785 (left-truncatable primes).
Cf. A137812 (left- or right-truncatable primes).
Cf. A227919 (primes which remain prime when rightmost digit is removed).

Programs

  • Maple
    KD:= proc() local a,b,c,d; a:=ithprime(n);b:=length(a); c:=floor(a/(10^(b-1)));d:=a-c*(10^(b-1));if isprime(d) then return(a):fi; end:seq(KD(),n=1..5000);

A227919 Primes which remain prime when rightmost digit is removed.

Original entry on oeis.org

23, 29, 31, 37, 53, 59, 71, 73, 79, 113, 131, 137, 139, 173, 179, 191, 193, 197, 199, 233, 239, 293, 311, 313, 317, 373, 379, 419, 431, 433, 439, 479, 593, 599, 613, 617, 619, 673, 677, 719, 733, 739, 797, 839, 971, 977, 1013, 1019, 1031, 1033, 1039, 1091, 1093
Offset: 1

Views

Author

K. D. Bajpai, Oct 10 2013

Keywords

Comments

After a(2), all the terms in this sequence have second digit from right 1, 3, 7, or 9.

Examples

			a(7)= 71 which is prime. Removing the rightmost digit gives 7, which is also prime.
a(16)= 191 which is prime. Removing the rightmost digit gives 19, which is also prime.
		

Crossrefs

Cf. A000040 (prime numbers), A024770 (right-truncatable primes).
Cf. A052025 (palindromic prime is prime right- or left-truncatable).
Cf. A137812 (left- or right-truncatable primes).

Programs

  • Maple
    KD:= proc() local a,b; a:= ithprime(n); b:=floor(a/10); if isprime(b) then return (a) :fi; end: seq(KD(),n=1..1000);
  • PARI
    is(n)=isprime(n) && isprime(n\10) \\ Charles R Greathouse IV, Oct 12 2013

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

A298048 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 left- or right-concatenating a digit to the a(n-1) primes obtained in the previous iteration.

Original entry on oeis.org

4, 16, 70, 243, 638, 1450, 2819, 4951, 7629, 10677, 13267, 15182, 15923, 15796, 14369, 12547, 10291, 7939, 5703, 3911, 2559, 1595, 920, 561, 321, 167, 72, 37, 11, 6, 3
Offset: 1

Views

Author

Seiichi Manyama, Jan 11 2018

Keywords

Comments

A137812 lists the primes counted here. - Jon E. Schoenfield, Jan 28 2022

Examples

			2-digit primes:
-------------------
23   2->23 or 3->23
29   2->29
13   3->13
43   3->43
53   3->53 or 5->53
73   3->73 or 7->73
83   3->83
31   3->31
37   3->37 or 7->37
59   5->59
17   7->17
47   7->47
67   7->67
97   7->97
71   7->71
79   7->79
-------------------
a(2) = 16.
===================
3-digit primes:
[223, 233, 523, 823, 239, 229, 293, 829, 929, 113, 131, 313, 613, 137, 139, 311, 331, 431, 631, 317, 433, 443, 643, 743, 439, 353, 653, 853, 953, 173, 373, 733, 673, 773, 739, 337, 937, 379, 283, 383, 683, 883, 983, 839, 359, 593, 659, 859, 599, 617, 179, 271, 571, 971, 719, 347, 547, 647, 947, 479, 167, 367, 467, 677, 967, 197, 397, 797, 977, 997]
In the case of 223, 2->23 (adding the rightmost digit)->223 (adding the leftmost digit) and 2, 23 and 223 are prime.
In the case of 233, 2->23 (adding the rightmost digit)->233 (adding the rightmost digit) and 2, 23 and 233 are prime.
In the case of 523, 2->23 (adding the rightmost digit)->523 (adding the leftmost digit) and 2, 23 and 523 are prime.
a(3) = 70.
		

Crossrefs

Programs

  • Mathematica
    Block[{b = 10, t}, t = Select[Range[b], CoprimeQ[#, b] &]; TakeWhile[Length /@ Fold[Function[{a, n}, Append[a, Union[Join @@ {Join @@ Map[Function[k, Select[Map[Prepend[k, #] &, Range[b - 1]], 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, 40]], # > 0 &]] (* Michael De Vlieger, Jan 21 2018 *)
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], []
      while len(primes) > 0:
        alst.append(len(primes))
        candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        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
  • Ruby
    require 'prime'
    def A298048(n)
      ary = [2, 3, 5, 7]
      a_ary = [4]
      (n - 1).times{|i|
        ary1 = []
        ary.each{|a|
          (1..9).each{|d|
            j = d * 10 ** (i + 1) + a
            ary1 << j if j.prime?
            j = a * 10 + d
            ary1 << j if j.prime?
          }
        }
        ary = ary1.uniq
        a_ary << ary.size
      }
      a_ary
    end
    p A298048(10)
    

Extensions

a(16)-a(31) from Michael De Vlieger, Jan 21 2018

A258032 Primes p such that p^3 with the rightmost digit removed is also prime.

Original entry on oeis.org

3, 17, 53, 113, 157, 233, 257, 277, 353, 359, 379, 397, 677, 877, 997, 1039, 1217, 1439, 1613, 1697, 1879, 1973, 1997, 2273, 2417, 2459, 2777, 3257, 3413, 3499, 3517, 3697, 3779, 4073, 4157, 4177, 4339, 4973, 4999, 5077, 5197, 5279, 5639, 5813, 5897, 6277, 6379
Offset: 1

Views

Author

K. D. Bajpai, May 16 2015

Keywords

Examples

			a(2) = 17 is prime: 17^3 = 4913. Removing rightmost digit gives 491 which is prime.
a(3) = 53 is prime: 53^3 = 148877. Removing rightmost digit gives 14887 which is prime.
		

Crossrefs

Programs

  • Haskell
    a258032 n = a258032_list !! (n-1)
    a258032_list = filter ((== 1) . a010051' . flip div 10. (^ 3)) a000040_list
    -- Reinhard Zumkeller, May 18 2015
  • Magma
    [p: p in PrimesUpTo(6500) |IsPrime(Floor(p^3/10))]; // Vincenzo Librandi, May 17 2015
    
  • Mathematica
    Select[Prime[Range[1000]], PrimeQ[Floor[(#^3)/10]] &]
  • PARI
    forprime(p=1,10000, if(isprime(floor((p^3)/10)), print1(p,", ")))
    

A289190 Numbers k such that k^2 with last digit deleted is a prime.

Original entry on oeis.org

5, 6, 14, 26, 44, 46, 56, 64, 74, 76, 86, 94, 106, 146, 154, 164, 206, 226, 236, 244, 254, 256, 274, 286, 296, 304, 314, 326, 344, 346, 364, 424, 436, 446, 454, 464, 506, 524, 536, 596, 614, 664, 674, 676, 686, 694, 706, 764, 776, 796, 826, 844, 854, 874, 944, 946
Offset: 1

Views

Author

K. D. Bajpai, Jun 27 2017

Keywords

Examples

			14 is in the sequence because 14^2 = 196; deleting the last digit gives 19 which is prime.
26 is in the sequence because 26^2 = 676; deleting the last digit gives 67 which is prime.
		

Crossrefs

Programs

  • Magma
    [n : n in [1 .. 2000] | IsPrime (Floor (n^2/10))];
    
  • Maple
    select(n -> isprime(floor(n^2/10)),[$1..2000]);
  • Mathematica
    fQ[n_] := PrimeQ@Quotient[n^2, 10]; Select[Range[1, 2000], fQ]
  • PARI
    isok(n) = isprime(n^2\10); \\ Michel Marcus, Jul 02 2017

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

Views

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()

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

Views

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)
Showing 1-10 of 10 results.