cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A383781 #13 May 15 2025 17:48:26
%S A383781 2,3,5,7,11,19,29,31,41,59,61,71,79,89,127,157,163,193,227,233,257,
%T A383781 263,277,293,433,457,463,487,557,563,577,587,593,677,727,733,757,787,
%U A383781 827,857,863,877,887,977,1129,1171,1231,1259,1279,1289,1319,1361,1429,1459
%N 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.
%C A383781 Is this sequence infinite?
%C A383781 See A383782 and the comment therein. - _Michael S. Branicky_, May 11 2025
%e A383781 127 is a term since 127 is a prime, 27 is a nonprime, and 7 is a prime;
%e A383781 13 is not a term since 13 and 3 are both prime.
%t A383781 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]
%o A383781 (Python)
%o A383781 from gmpy2 import is_prime, mpz
%o A383781 from itertools import count, islice
%o A383781 def agen():
%o A383781     olst, elst = [2, 3, 5, 7], [11, 19, 29, 31, 41, 59, 61, 71, 79, 89]
%o A383781     for n in count(1):
%o A383781         yield from sorted(olst + elst)
%o A383781         olst2, elst2 = [], []
%o A383781         for o in olst:
%o A383781             o, base = o, 10**(2*n-1)
%o A383781             for i in range(10*base, 100*base, base):
%o A383781                 t = i + o
%o A383781                 t2 = int(str(t)[1:])
%o A383781                 if is_prime(t) and not is_prime(t2):
%o A383781                     olst2.append(t)
%o A383781         for e in elst:
%o A383781             e, base = e, 10**(2*n)
%o A383781             for i in range(10*base, 100*base, base):
%o A383781                 t = i + e
%o A383781                 t2 = int(str(t)[1:])
%o A383781                 if is_prime(t) and not is_prime(t2):
%o A383781                     elst2.append(t)
%o A383781         olst, elst = olst2, elst2
%o A383781 print(list(islice(agen(), 68))) # _Michael S. Branicky_, May 11 2025
%Y A383781 Cf. A024785, A383780, A383782.
%K A383781 nonn,base
%O A383781 1,1
%A A383781 _Stefano Spezia_, May 09 2025