OFFSET
1,2
COMMENTS
The integer 10 is the first one that will never appear in the sequence (as the result of 1 + 3*0 is not a prime). The next absent will be 11.
From Michael S. Branicky, Apr 19 2023: (Start)
The only pairs AB allowed are 01, 12, 14, 16, 20, 21, 23, 25, 27, 29, 30, 41, 43, 45, 49, 50, 52, 54, 56, 58, 70, 72, 74, 78, 81, 83, 85, 87.
Further, any appearance of 6 or 9 as a digit would end the sequence, as would a term with last digit 3 (since next term cannot start with 0).
As long as no term ends in 3, 6, 9, the sequence is infinitely extensible since the cycle 01 -> 12 -> 20 -> 01 (at least) can be used to extend terms ending in 0, 1, or 2; the cycle 45 -> 54 -> 45 can be used to extend terms ending in 4 or 5; and 78 -> 87 -> 78 to extend terms ending in 7 or 8. (End)
EXAMPLE
a(2) = 2 since the adjacent digits A=1 and B=2 are allowed (A+3B = 7 is prime).
a(3) is not 3 since a number ending 3 is never infinitely extensible, and not 4 since adjacent digits A=2 and B=4 are not allowed (A+3B = 14 not prime), but B=5 is allowed so a(3) = 5.
a(5) = 12 is the first 2-digit term and the digit pair 4,1 with the preceding a(4) is allowed, and also its own adjacent digits 1,2.
Digit A = 1 and B = 2 lead to 7 (prime) = A+3B;
Digit A = 2 and B = 5 lead to 17 (prime) = A+3B;
Digit A = 5 and B = 4 lead to 17 (prime) = A+3B;
Digit A = 4 and B = 1 lead to 7 (prime) = A+3B;
Digit A = 1 and B = 2 lead to 7 (prime) = A+3B;
Digit A = 2 and B = 1 lead to 5 (prime) = A+3B;
Digit A = 1 and B = 4 lead to 13 (prime) = A+3B; etc.
PROG
(Python)
from sympy import isprime
from itertools import islice
def c(s):
if s[-1] == "3" or "6" in s or "9" in s: return False
return all(isprime(int(s[i])+3*int(s[i+1])) for i in range(len(s)-1))
def agen(): # generator of terms
last, aset = "1", {1}
yield 1
while True:
k = 2
while k in aset or not c(last+str(k)): k += 1
an = k; yield an; last = str(an%10); aset.add(an)
print(list(islice(agen(), 58))) # Michael S. Branicky, Apr 19 2023
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini, Apr 19 2023
EXTENSIONS
a(6)-a(7) inserted and a(21) and beyond from Michael S. Branicky, Apr 19 2023
STATUS
approved