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.
%I A158652 #18 Jul 13 2022 02:08:28 %S A158652 1,2,3,4,7,41,43,47,49,83,85,89,202,302,303,411,412,502,503,830,2020, %T A158652 2021,2023,2025,2029,2030,2032,3020,3021,4111,4112,5020,5021,6111, %U A158652 6112,9202,9203,20202,30202,30203,41111,41112,50202,50203,83020,202020 %N A158652 Any two consecutive digits in the sequence sum up to a prime. %C A158652 a(1)=1 and a(n) is always the smallest integer > a(n-1) not leading to a contradiction. Terms computed by _M. F. Hasler_. %C A158652 From _M. F. Hasler_, Mar 24 2009: (Start) %C A158652 After the initial 2,3,4,7,41,43,47,49,83,85,89, the following pattern repeats: %C A158652 202,302,303, %C A158652 411,412,502,503,830, %C A158652 2020,2021,2023,2025,2029,2030,2032,3020,3021, %C A158652 4111,4112,5020,5021,6111,6112,9202,9203, %C A158652 with each time two extra digits (either 02 or 11): %C A158652 20202,30202,30203, %C A158652 41111,41112,50202,50203,83020, %C A158652 202020,202021,202023,202025,202029,202030,202032,302020,302021, %C A158652 411111,411112,502020,502021,611111,611112,920202,920203, %C A158652 and so on. (End) %H A158652 Robert G. Wilson v, <a href="/A158652/b158652.txt">Table of n, a(n) for n=1..100 </a> %H A158652 Eric Angelini, <a href="http://www.cetteadressecomportecinquantesignes.com/ConsecDig.htm">Chiffres consecutifs dans quelques suites</a> %H A158652 Eric Angelini, <a href="/A152136/a152136.pdf">Chiffres consecutifs dans quelques suites</a> [Cached copy, with permission] %t A158652 f[s_List] := Block[{k = s[[ -1]] + 1, ls = Mod[ s[[ -1]], 10]}, While[ Union@ PrimeQ[ Plus @@@ Partition[ Join[{ls}, IntegerDigits@ k], 2, 1]] != {True}, k++ ]; Append[s, k]]; Nest[f, {1}, 45] (* _Robert G. Wilson v_, Apr 05 2009 *) %o A158652 (Python) %o A158652 from itertools import count, islice %o A158652 allowed = {"0":"2357", "1":"1246", "2":"01359", "3":"0248", "4":"1379", "5":"0268", "6":"157", "7":"046", "8":"359", "9":"248"} %o A158652 def cgen(seed, digits, geq="0"): # numbers satisfying the condition %o A158652 if digits == 1: %o A158652 yield from (c for c in allowed[seed] if c >= geq); return %o A158652 for f in (c for c in allowed[seed] if c >= geq): %o A158652 yield from (f + r for r in cgen(f, digits-1)) %o A158652 def nextc(k): # next element of cgen greater than k %o A158652 s = str(k) %o A158652 for d in count(len(s)): %o A158652 geq = s[0] if d == len(s) else "1" %o A158652 for c in map(int, cgen(s[-1], d, geq=geq)): %o A158652 if c > k: return c %o A158652 def agen(): %o A158652 an = 1 %o A158652 for n in count(1): yield an; an = nextc(an) %o A158652 print(list(islice(agen(), 40))) # _Michael S. Branicky_, Jul 12 2022 %Y A158652 Cf. A152603-A152610. %K A158652 base,nonn %O A158652 1,2 %A A158652 _Eric Angelini_, Mar 23 2009