Displaying 1-10 of 11 results found.
Right-truncatable primes: every prefix is prime.
+10
56
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
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
LINKS
R. Schroeppel, HAKMEM item 33; "Russian Doll Primes", but with a slightly different definition.
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 *)
PROG
(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
(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
CROSSREFS
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.
KEYWORD
nonn,base,easy,fini,full,nice,tabf
Left-truncatable primes: every suffix is prime and no digits are zero.
+10
43
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
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
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:
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 *)
PROG
(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
(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
(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
CROSSREFS
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.
KEYWORD
nonn,base,easy,fini,full,tabf
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
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
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:
MATHEMATICA
h8pQ[n_]:=And@@PrimeQ/@Most[NestWhileList[FromDigits[Rest[ IntegerDigits[ #]]]&, n, #>0&]]; Select[Prime[Range[1000]], h8pQ] (* Harvey P. Dale, May 26 2011 *)
PROG
(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
(Haskell)
a033664 n = a033664_list !! (n-1)
a033664_list = filter (all ((== 1) . a010051. read) .
init . tail . tails . show) a000040_list
(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)))
(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
CROSSREFS
Cf. A024785, A032437, A020994, A024770, A052023, A052024, A052025, A050986, A050987, A069866, A038680, A010051, A000040.
Primes that are both left-truncatable and right-truncatable.
+10
18
2, 3, 5, 7, 23, 37, 53, 73, 313, 317, 373, 797, 3137, 3797, 739397
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
REFERENCES
David Wells, The Penguin Dictionary of Curious and Interesting Numbers, p. 178 (Rev. ed. 1997).
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]
CROSSREFS
Cf. A033664, A024785, A032437, A024770, A052023, A052024, A052025, A050986, A050987, A254751, A254753.
AUTHOR
Mario Velucchi (mathchess(AT)velucchi.it)
Number of n-digit right-truncatable primes.
+10
18
4, 9, 14, 16, 15, 12, 8, 5, 0
COMMENTS
Right-truncatable means that the integer part of successive divisions by 10 always yields primes (or zero). - M. F. Hasler, Nov 07 2018
PROG
(PARI) A050986=vector(9, n, #p=concat(apply(t->primes([t, t+1]*10), if(n>1, p)))) \\ M. F. Hasler, Nov 07 2018
Number of n-digit left-truncatable primes.
+10
18
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
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
PROG
(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
Every prefix (or suffix) of palindromic prime a(n) is prime (right/left-truncatable).
+10
18
2, 3, 5, 7, 313, 373, 797
LINKS
C. K. Caldwell, Left and Right truncatable primes.
Substrings from the right are prime numbers (using only odd digits different from 5).
+10
12
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
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
EXAMPLE
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
MATHEMATICA
Select[Prime[Range[33000]], SubsetQ[{1, 3, 7, 9}, IntegerDigits[#]]&&AllTrue[Mod[#, 10^Range[ IntegerLength[ #]-1]], PrimeQ]&] (* Harvey P. Dale, Jun 28 2022 *)
PROG
(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
Every suffix of palindromic prime a(n), containing no '0' digit, is prime (left-truncatable palindromic primes).
+10
12
2, 3, 5, 7, 313, 353, 373, 383, 797, 76367, 79397, 7693967, 799636997
LINKS
C. K. Caldwell, Left and Right truncatable primes.
MATHEMATICA
d[n_]:=IntegerDigits[n]; ltrQ[n_]:=And@@PrimeQ[NestList[FromDigits[Drop[d[#], 1]]&, n, Length[d[n]]-1]]; palQ[n_]:=Reverse[x=d[n]]==x; Select[Prime[Range[540000]], palQ[#]&<rQ[#]&] (* Jayanta Basu, Jun 02 2013 *)
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
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?
EXAMPLE
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
Cf. A000040, A024770, A033664, A024785 (left-truncatable primes), A032437, A020994, A052023, A052024, A052025, A050986, A050987, A069866.
Search completed in 0.014 seconds
|