# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a152607 Showing 1-1 of 1 %I A152607 #12 Jul 13 2022 03:41:00 %S A152607 1,3,7,9,71,73,79,711,713,717,971,973,1111,1113,1117,1119,7111,7113, %T A152607 7117,9711,9713,11111,11113,11117,11119,71111,71113,71117,97111,97113, %U A152607 111111,111113,111117,111119,711111,711113,711117,971111 %N A152607 a(1) = 1; thereafter a(n) is always the smallest integer > a(n-1) not leading to a contradiction, such that the concatenation of any two consecutive digits in the sequence is a prime. %C A152607 Computed by Jean-Marc Falcoz. %C A152607 Comment from Jean-Marc Falcoz: (Start) %C A152607 The sequence is infinite since it has the following structure: %C A152607 9713, 11111, 11113, 11117, 11119, 71111, 71113, 71117, 97111, %C A152607 97113, 111111, 111113, 111117, 111119, 711111, 711113, 711117, 971111, %C A152607 971113, 1111111, 1111113, 1111117, 1111119, 7111111, 7111113, 7111117, 9711111, %C A152607 9711113, 11111111, 11111113, 11111117, 11111119, 71111111, 71111113, 71111117, 97111111, %C A152607 97111113, 111111111, 111111113, 111111117, 111111119, 711111111, 711111113, 711111117, 971111111, %C A152607 971111113, 1111111111, 1111111113, 1111111117, 1111111119, 7111111111, 7111111113, 7111111117, 9711111111, %C A152607 9711111113, ... (End) %H A152607 Eric Angelini, Chiffres consecutifs dans quelques suites %H A152607 Eric Angelini, Chiffres consecutifs dans quelques suites [Cached copy, with permission] %o A152607 (Python) %o A152607 from itertools import count, islice %o A152607 def cgen(seed, digits, geq="0"): # numbers satisfying the condition %o A152607 allowed = {"1": "1379", "3": "17", "7": "139", "9": "7"} %o A152607 if digits == 1: %o A152607 yield from (c for c in allowed[seed] if c >= geq); return %o A152607 for f in (c for c in allowed[seed] if c >= geq): %o A152607 yield from (f + r for r in cgen(f, digits-1)) %o A152607 def nextc(k): # next element of cgen greater than k %o A152607 s = str(k) %o A152607 for d in count(len(s)): %o A152607 geq = s[0] if d == len(s) else "0" %o A152607 for c in map(int, cgen(s[-1], d, geq=geq)): %o A152607 if c > k: return c %o A152607 def agen(): %o A152607 an = 1 %o A152607 for n in count(1): yield an; an = nextc(an) %o A152607 print(list(islice(agen(), 40))) # _Michael S. Branicky_, Jul 12 2022 %o A152607 (Python) # alternate using pattern from comments %o A152607 from itertools import count, islice %o A152607 def agen(): %o A152607 yield from [1, 3, 7, 9, 71, 73, 79, 711, 713, 717, 971] %o A152607 for i in count(0): %o A152607 i1 = "1"*i %o A152607 yield from map(int, ("97"+i1+"3", i1+"1111", i1+"1113", i1+"1117", i1+"1119", "7111"+i1, "711"+i1+"3", "711"+i1+"7", "9711"+i1)) %o A152607 print(list(islice(agen(), 40))) # _Michael S. Branicky_, Jul 12 2022 %Y A152607 Cf. A158652, A152604-A152609. See A152136 for another version. %K A152607 nonn,base %O A152607 1,2 %A A152607 _N. J. A. Sloane_, Sep 23 2009 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE