A362418 Beginning with 1, smallest positive integer not yet in the sequence such that two adjacent digits A and B of the sequence (also ignoring commas between terms) produce a prime = A + 3B. This is the earliest infinitely extensible such sequence.
1, 2, 5, 4, 12, 7, 8, 14, 30, 120, 121, 20, 125, 21, 25, 27, 41, 45, 81, 201, 212, 50, 127, 85, 87, 214, 52, 54, 58, 70, 141, 230, 145, 250, 1201, 252, 72, 74, 301, 254, 501, 258, 78, 520, 1212, 521, 270, 1214, 525, 272, 527, 274, 541, 278, 545, 412, 581, 414
Offset: 1
Examples
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.
Programs
-
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
Extensions
a(6)-a(7) inserted and a(21) and beyond from Michael S. Branicky, Apr 19 2023
Comments