OFFSET
1,3
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
EXAMPLE
a(9) = 5, a(10) = 10, a(11) = 20, a(12) = 13, a(13) = 14, a(14) = 21 ; we see that a(9) and a(12) are primes and that a(10), a(11), a(13); and a(14) are nonprimes. The digits involved fit the pattern nonprime/nonprime/prime too; they are 5,1,0,2,0,1,3,1,4,2 and 1.
PROG
(Python)
from sympy import isprime
from itertools import count, islice, product
def bgen(i): # generates terms with np/np/p, np/p/np, or p/np/np 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