OFFSET
1,2
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
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.
PROG
(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
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Jean-Marc Falcoz, Aug 12 2024
STATUS
approved