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 12 results. Next

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

A033664 Every suffix is prime.

Original entry on oeis.org

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

Views

Author

Keywords

Comments

Primes in which repeatedly deleting the most significant digit gives a prime at every step until a single-digit prime remains.
Every digit string containing the least significant digit is prime. - Amarnath Murthy, Sep 24 2003

Crossrefs

Programs

  • Haskell
    a033664 n = a033664_list !! (n-1)
    a033664_list = filter (all ((== 1) . a010051. read) .
                               init . tail . tails . show) a000040_list
    -- Reinhard Zumkeller, Jul 10 2013
    
  • Maple
    T:= proc(n) option remember; `if`(n=0, "", select(isprime, [seq(seq(
          seq(parse(cat(j, 0$(n-i), p)), p=[T(i-1)]), i=1..n), j=1..9)])[])
        end:
    seq(T(n), n=1..4);  # Alois P. Heinz, Sep 01 2021
  • Mathematica
    h8pQ[n_]:=And@@PrimeQ/@Most[NestWhileList[FromDigits[Rest[ IntegerDigits[ #]]]&, n,#>0&]]; Select[Prime[Range[1000]],h8pQ] (* Harvey P. Dale, May 26 2011 *)
  • PARI
    fileO="b033664.txt";lim=8779;v=vector(lim);v[1]=2;v[2]=3;v[3]=5;v[4]=7;j=4; write(fileO,"1 2");write(fileO,"2 3");write(fileO,"3 5");write(fileO,"4 7"); p10=1;until(0,p10*=10;j0=j;for(k=1,9,k10=k*p10; for(i=1,j0,if(j==lim,break(3));z=k10+v[i]; if(isprime(z),j++;v[j]=z;write(fileO,j," ",z);)))) \\ Harry J. Smith, Sep 20 2008
    
  • Python
    from sympy import isprime, primerange
    def ok(p): # does prime p satisfy the property
        s = str(p)
        return all(isprime(int(s[i:])) for i in range(1, len(s)))
    print(list(filter(ok, primerange(1, 1000)))) # Michael S. Branicky, Sep 01 2021
    
  • Python
    # alternate for going to large numbers
    def agen(maxdigits):
        yield from [2, 3, 5, 7]
        primestrs, digits, d = ["2", "3", "5", "7"], "0123456789", 1
        while len(primestrs) > 0 and d < maxdigits:
            cands = set(d+p for p in primestrs for d in "0123456789")
            primestrs = [c for c in cands if c[0] == "0" or isprime(int(c))]
            yield from sorted(map(int, (p for p in primestrs if p[0] != "0")))
            d += 1
    print([p for p in agen(11)]) # Michael S. Branicky, Sep 01 2021

Extensions

More terms from Erich Friedman

A020994 Primes that are both left-truncatable and right-truncatable.

Original entry on oeis.org

2, 3, 5, 7, 23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397
Offset: 1

Views

Author

Mario Velucchi (mathchess(AT)velucchi.it)

Keywords

Comments

Two-sided primes: deleting any number of digits at left or at right, but not both, leaves a prime.
Primes in which every digit string containing the most significant digit or the least significant digit is prime. - Amarnath Murthy, Sep 24 2003
Intersection of A024785 and A024770. - Robert Israel, Mar 23 2015

References

  • David Wells, The Penguin Dictionary of Curious and Interesting Numbers, p. 178 (Rev. ed. 1997).

Crossrefs

Programs

  • Mathematica
    tspQ[n_] := Module[{idn=IntegerDigits[n], l}, l=Length[idn]; Union[PrimeQ/@(FromDigits/@ Join[Table[Take[idn, i], {i, l}], Table[Take[idn, -i], {i, l}]])]=={True}] Select[Prime[Range[PrimePi[740000]]], tspQ]

Extensions

Corrected by David W. Wilson
Additional comments from Harvey P. Dale, Jul 10 2002

A050986 Number of n-digit right-truncatable primes.

Original entry on oeis.org

4, 9, 14, 16, 15, 12, 8, 5, 0
Offset: 1

Views

Author

Keywords

Comments

Right-truncatable means that the integer part of successive divisions by 10 always yields primes (or zero). - M. F. Hasler, Nov 07 2018

Crossrefs

Programs

  • PARI
    A050986=vector(9, n, #p=concat(apply(t->primes([t, t+1]*10), if(n>1, p)))) \\ M. F. Hasler, Nov 07 2018

Extensions

Edited by Ray Chandler, Mar 13 2007
a(9) = 0 added by M. F. Hasler, Nov 07 2018

A050987 Number of n-digit left-truncatable primes.

Original entry on oeis.org

4, 11, 39, 99, 192, 326, 429, 521, 545, 517, 448, 354, 276, 212, 117, 72, 42, 24, 13, 6, 5, 4, 3, 1, 0
Offset: 1

Views

Author

Keywords

Comments

The sequence is well defined for any positive integer, with a(n) = 0 for n >= 25. But it makes sense to consider it to be full & finite. - M. F. Hasler, Nov 07 2018

Crossrefs

Programs

  • PARI
    A050987=vector(25, n, #p=concat(apply(p->select(isprime, vector(9, i, i*10^(n-1)+p)), if(n>1, p)))) \\ M. F. Hasler, Nov 07 2018
    
  • Python
    from sympy import isprime
    def alst():
      primes, alst = [2, 3, 5, 7], [4]
      while len(primes) > 0:
        candidates = set(int(d+str(p)) for p in primes for d in "123456789")
        primes = [c for c in candidates if isprime(c)]
        alst.append(len(primes))
      return alst
    print(alst()) # Michael S. Branicky, Apr 11 2021

Extensions

Edited by Ray Chandler, Mar 13 2007
a(25) = 0 added by M. F. Hasler, Nov 07 2018

A052025 Every prefix (or suffix) of palindromic prime a(n) is prime (right/left-truncatable).

Original entry on oeis.org

2, 3, 5, 7, 313, 373, 797
Offset: 1

Views

Author

Keywords

Crossrefs

A032437 Substrings from the right are prime numbers (using only odd digits different from 5).

Original entry on oeis.org

3, 7, 13, 17, 37, 73, 97, 113, 137, 173, 197, 313, 317, 337, 373, 397, 773, 797, 937, 997, 1373, 1997, 3137, 3313, 3373, 3797, 7937, 9137, 9173, 9337, 9397, 13313, 33797, 39397, 79337, 79397, 91373, 91997, 99137, 99173, 99397, 139397, 379397
Offset: 1

Views

Author

Keywords

Comments

Primes p with decimal expansion d_1 d_2 d_3 ... d_k such that the digits d_i are 1, 3, 7, or 9, and deleting 1, 2, 3, up to k-1 leading digits also produces a prime. For example, 9173 is a term because all of 9173, 173, 73, and 3 are primes. - N. J. A. Sloane, Jun 28 2022

Examples

			173 is a term because 173, 73, and 3 are all primes. 371 is not a term because 371 and 1 are not primes. - _N. J. A. Sloane_, Jun 28 2022
		

Crossrefs

Programs

  • Mathematica
    Select[Prime[Range[33000]],SubsetQ[{1,3,7,9},IntegerDigits[#]]&&AllTrue[Mod[#,10^Range[ IntegerLength[ #]-1]],PrimeQ]&] (* Harvey P. Dale, Jun 28 2022 *)
  • PARI
    is(n)=my(d=digits(n)); for(i=1,n, if(!isprime(fromdigits(d[i..n])), return(0))); 1 \\ Charles R Greathouse IV, Jun 25 2017

Extensions

Single-digit terms added by Eric W. Weisstein.

A052024 Every suffix of palindromic prime a(n) is prime (left-truncatable).

Original entry on oeis.org

2, 3, 5, 7, 313, 353, 373, 383, 797, 30103, 31013, 70607, 73037, 76367, 79397, 3002003, 7096907, 7693967, 700090007, 799636997, 70060906007, 3000002000003, 7030000000307, 300000020000003, 300001030100003, 310000060000013, 38000000000000000000083, 30000000004000300040000000003, 3000001000000000000000000000001000003
Offset: 1

Views

Author

Keywords

Crossrefs

Programs

  • Mathematica
    d[n_]:=IntegerDigits[n]; ltrQ[n_]:=And@@PrimeQ[NestWhileList[FromDigits[Drop[d[#],1]]&,n,#>9&]]; palQ[n_]:=Reverse[x=d[n]]==x; Select[Prime[Range[550000]],palQ[#]&<rQ[#]&] (* Jayanta Basu, Jun 02 2013 *)
  • Python
    from sympy import isprime
    from itertools import count, islice
    def agen(verbose=False):
        prime_strings, alst = {"3", "7"}, []
        yield from [2, 3, 5, 7]
        for digs in count(2):
            new_prime_strings = set()
            for p in prime_strings:
                for d in "123456789":
                    ts = d + "0"*(digs-1-len(p)) + p
                    if isprime(int(ts)):
                        new_prime_strings.add(ts)
            prime_strings |= new_prime_strings
            pals = [int(s) for s in new_prime_strings if s == s[::-1]]
            yield from sorted(pals)
            if verbose: print("...", digs, len(prime_strings), time()-time0)
    print(list(islice(agen(), 20))) # Michael S. Branicky, Apr 04 2022

Extensions

Inserted missing 31013 by Jayanta Basu, Jun 02 2013
a(27)-a(29) from Michael S. Branicky, Apr 04 2022

A173057 Partial sums of A024770.

Original entry on oeis.org

2, 5, 10, 17, 40, 69, 100, 137, 190, 249, 320, 393, 472, 705, 944, 1237, 1548, 1861, 2178, 2551, 2930, 3523, 4122, 4841, 5574, 6313, 7110, 9443, 11782, 14175, 16574, 19513, 22632, 25769, 29502, 33241, 37034, 40831, 46770, 53963, 61294, 68627
Offset: 1

Views

Author

Jonathan Vos Post, Feb 08 2010

Keywords

Comments

Partial sums of right-truncatable primes, primes whose every prefix is prime (in decimal representation). The sequence has 83 terms. The subsequence of prime partial sums of right-truncatable primes begins: 2, 5, 17, 137, 1237, 1861, 2551, 199483. What is the largest value in the subsubsequence of right-truncatable prime partial sums of right-truncatable primes?

Examples

			a(50) = 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 + 31379.
		

Crossrefs

Showing 1-10 of 12 results. Next