login
A383781
Primes where successively deleting the most significant digit yields a sequence that alternates between a prime and a nonprime at every step until a single-digit number remains.
2
2, 3, 5, 7, 11, 19, 29, 31, 41, 59, 61, 71, 79, 89, 127, 157, 163, 193, 227, 233, 257, 263, 277, 293, 433, 457, 463, 487, 557, 563, 577, 587, 593, 677, 727, 733, 757, 787, 827, 857, 863, 877, 887, 977, 1129, 1171, 1231, 1259, 1279, 1289, 1319, 1361, 1429, 1459
OFFSET
1,1
COMMENTS
Is this sequence infinite?
See A383782 and the comment therein. - Michael S. Branicky, May 11 2025
EXAMPLE
127 is a term since 127 is a prime, 27 is a nonprime, and 7 is a prime;
13 is not a term since 13 and 3 are both prime.
MATHEMATICA
Unprotect[CompositeQ]; CompositeQ[1]:=True; Protect[CompositeQ]; Q[n_]:=And[AllTrue[FromDigits/@Table[Take[IntegerDigits[n], -i], {i, IntegerLength[n], 1, -2}], PrimeQ], AllTrue[FromDigits/@Table[Take[IntegerDigits[n], -i], {i, IntegerLength[n]-1, 1, -2}], CompositeQ]]; Select[Prime[Range[240]], Q]
PROG
(Python)
from gmpy2 import is_prime, mpz
from itertools import count, islice
def agen():
olst, elst = [2, 3, 5, 7], [11, 19, 29, 31, 41, 59, 61, 71, 79, 89]
for n in count(1):
yield from sorted(olst + elst)
olst2, elst2 = [], []
for o in olst:
o, base = o, 10**(2*n-1)
for i in range(10*base, 100*base, base):
t = i + o
t2 = int(str(t)[1:])
if is_prime(t) and not is_prime(t2):
olst2.append(t)
for e in elst:
e, base = e, 10**(2*n)
for i in range(10*base, 100*base, base):
t = i + e
t2 = int(str(t)[1:])
if is_prime(t) and not is_prime(t2):
elst2.append(t)
olst, elst = olst2, elst2
print(list(islice(agen(), 68))) # Michael S. Branicky, May 11 2025
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Stefano Spezia, May 09 2025
STATUS
approved