OFFSET
1,1
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
a(4) = 5, a(5) = 7, a(6) = 1, a(7) = 23, a(8) = 13, a(9) = 20; we see that a(4), a(5), a(7) and a(8) are primes and that a(6) and a(9) are nonprimes. The digits involved fit the pattern prime/prime/nonprime too; they are 5,7,1,2,3,1,3,2 and 0.
PROG
(Python)
from sympy import isprime
from itertools import count, islice, product
def bgen(i): # generates terms with p/p/np, p/np/p, or np/p/p digits
digs = ["014689", "2357"]
for digits in count(1):
patt = [digs[(i+j)%3 < 2] for j in range(digits)]
yield from (int("".join(s)) for s in product(*patt) if digits==1 or s[0]!="0")
def agen(): # generator of terms
seen, s = set(), 0
for n in count(1):
p = (n-1)%3 < 2
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 13 2024
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Jean-Marc Falcoz, Aug 13 2024
STATUS
approved