A383779 Primes where successively deleting the least significant digit yields a sequence that alternates between a prime and a nonprime at every step until a single-digit number remains.
2, 3, 5, 7, 11, 13, 17, 19, 41, 43, 47, 61, 67, 83, 89, 97, 211, 223, 227, 229, 241, 251, 257, 263, 269, 271, 277, 281, 283, 307, 331, 337, 347, 349, 353, 359, 367, 383, 389, 397, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 701, 709, 727, 743, 751, 757, 761, 769, 773, 787
Offset: 1
Examples
211 is a term since 211 is a prime, 21 is a nonprime, and 2 is a prime; 23 is not a term since 23 and 2 are both prime.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..20000
- Michael S. Branicky, Largest even-length (= 108 digits) then odd-length (= 113 digits) terms
Programs
-
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[140]], Q]
-
Python
from gmpy2 import is_prime, mpz from itertools import count, islice def agen(): olst, elst = [2, 3, 5, 7], [11, 13, 17, 19, 41, 43, 47, 61, 67, 83, 89, 97] yield from olst + elst for n in count(1): olst2, elst2 = [], [] for o in olst: for i in range(1, 100, 2): t = 100*o + i if is_prime(t) and not is_prime(t//10): olst2.append(t) yield from olst2 for e in elst: for i in range(100): t = 100*e + i if is_prime(t) and not is_prime(t//10): elst2.append(t) yield from elst2 olst, elst = olst2, elst2 print(list(islice(agen(), 70))) # Michael S. Branicky, May 11 2025
-
Python
# predicate test useful for large n (cf. a-file of largest terms) from gmpy2 import digits, is_prime, mpz def ok(n): s = digits(n) return is_prime(n) and all(int(is_prime(mpz(s[:-i]))) == 1-i&1 for i in range(1, len(s))) # Michael S. Branicky, May 16 2025
Comments