A375326 Terms as well as digits fit the nonprime/prime pattern; this is the lexicographically earliest injective sequence with this property.
0, 2, 1, 3, 4, 5, 6, 7, 8, 29, 20, 31, 21, 59, 24, 71, 26, 79, 28, 263, 9, 283, 12, 13, 15, 17, 42, 43, 45, 47, 62, 67, 63, 83, 65, 97, 82, 131, 30, 293, 85, 139, 34, 307, 87, 151, 36, 313, 92, 179, 38, 317, 93, 421, 39, 347, 95, 431, 50, 367, 120, 383, 121, 397, 124, 503, 126, 547, 128, 563, 129, 587, 130
Offset: 1
Examples
a(9) = 8, a(10) = 29, a(11) = 20, a(12) = 31; we see that a(9) and a(11) are nonprimes and that a(10) and a(12) are primes. The digits involved fit the pattern nonprime/prime too; they are 8, 2, 9, 2, 0, 3, 1.
Links
- Michael S. Branicky, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A217555.
Programs
-
Python
from sympy import isprime from itertools import count, islice, product def bgen(i): # generates terms with prime/nonprime or nonprime/prime digits digs = ["014689", "2357"] for digits in count(1): patt = [digs[(i+j)&1] for j in range(digits)] yield from (int("".join(s)) for s in product(*patt) if s[0]!="0") def agen(): # generator of terms seen, s, an = {0, 2}, 2, 2 yield from [0, 2] for n in count(3): p = (n&1) == 0 an = next(k for k in bgen(s) if k not in seen and isprime(k)==p) yield an seen.add(an) s += len(str(an)) print(list(islice(agen(), 99))) # Michael S. Branicky, Aug 12 2024