[go: up one dir, main page]

login
A052024
Every suffix of palindromic prime a(n) is prime (left-truncatable).
11
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,1
LINKS
I. O. Angell and H. J. Godwin, On Truncatable Primes, Math. Comput. 31, 265-267, 1977.
C. K. Caldwell, Left and Right truncatable primes.
Eric Weisstein's World of Mathematics, Prime strings
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[#]&&ltrQ[#]&] (* Jayanta Basu, Jun 02 2013 *)
PROG
(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
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
Inserted missing 31013 by Jayanta Basu, Jun 02 2013
a(27)-a(29) from Michael S. Branicky, Apr 04 2022
STATUS
approved