login
Left- or right-truncatable primes, restricted to one consecutive zero.
1

%I #22 Nov 25 2023 23:54:42

%S 2,3,5,7,13,17,23,29,31,37,43,47,53,59,67,71,73,79,83,97,103,107,113,

%T 131,137,139,167,173,179,197,223,229,233,239,271,283,293,307,311,313,

%U 317,331,337,347,353,359,367,373,379,383,397,431,433,439,443,467,479,503

%N Left- or right-truncatable primes, restricted to one consecutive zero.

%C There are 16484138 primes in this list, in total. The largest one has 60 digits and there is only one of that length.

%o (Python)

%o from sympy import isprime

%o route = set({})

%o nums = [i*(10**j) for i in range(1, 10) for j in range(2)]

%o def addnum(a):

%o global route

%o for j in nums:

%o b = int("{}{}".format(a, j))

%o if isprime(b):

%o if b not in route:

%o route.add(b)

%o addnum(b)

%o for j in nums:

%o b = int("{}{}".format(j, a))

%o if isprime(b):

%o if b not in route:

%o route.add(b)

%o addnum(b)

%o def run():

%o for i in nums:

%o if isprime(i):

%o addnum(i)

%Y Left- or right-truncatable primes, excluding all 0s: A137812.

%Y The number of primes of length n following these rules: A346662.

%K nonn,fini

%O 1,1

%A _Timothy Smith_, Jan 25 2022