cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

This page as a plain text file.
%I A362418 #28 Apr 23 2023 17:12:08
%S A362418 1,2,5,4,12,7,8,14,30,120,121,20,125,21,25,27,41,45,81,201,212,50,127,
%T A362418 85,87,214,52,54,58,70,141,230,145,250,1201,252,72,74,301,254,501,258,
%U A362418 78,520,1212,521,270,1214,525,272,527,274,541,278,545,412,581,414
%N 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.
%C A362418 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.
%C A362418 From _Michael S. Branicky_, Apr 19 2023: (Start)
%C A362418 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.
%C A362418 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).
%C A362418 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)
%e A362418 a(2) = 2 since the adjacent digits A=1 and B=2 are allowed (A+3B = 7 is prime).
%e A362418 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.
%e A362418 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.
%e A362418 Digit A = 1 and B = 2 lead to 7 (prime) = A+3B;
%e A362418 Digit A = 2 and B = 5 lead to 17 (prime) = A+3B;
%e A362418 Digit A = 5 and B = 4 lead to 17 (prime) = A+3B;
%e A362418 Digit A = 4 and B = 1 lead to 7 (prime) = A+3B;
%e A362418 Digit A = 1 and B = 2 lead to 7 (prime) = A+3B;
%e A362418 Digit A = 2 and B = 1 lead to 5 (prime) = A+3B;
%e A362418 Digit A = 1 and B = 4 lead to 13 (prime) = A+3B; etc.
%o A362418 (Python)
%o A362418 from sympy import isprime
%o A362418 from itertools import islice
%o A362418 def c(s):
%o A362418     if s[-1] == "3" or "6" in s or "9" in s: return False
%o A362418     return all(isprime(int(s[i])+3*int(s[i+1])) for i in range(len(s)-1))
%o A362418 def agen(): # generator of terms
%o A362418     last, aset = "1", {1}
%o A362418     yield 1
%o A362418     while True:
%o A362418         k = 2
%o A362418         while k in aset or not c(last+str(k)): k += 1
%o A362418         an = k; yield an; last = str(an%10); aset.add(an)
%o A362418 print(list(islice(agen(), 58))) # _Michael S. Branicky_, Apr 19 2023
%Y A362418 Cf. A182178 (B is multiplied by 1), A362417 (B is multiplied by 2).
%K A362418 base,nonn
%O A362418 1,2
%A A362418 _Eric Angelini_, Apr 19 2023
%E A362418 a(6)-a(7) inserted and a(21) and beyond from _Michael S. Branicky_, Apr 19 2023