Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #12 Jul 13 2022 03:41:00
%S 1,3,7,9,71,73,79,711,713,717,971,973,1111,1113,1117,1119,7111,7113,
%T 7117,9711,9713,11111,11113,11117,11119,71111,71113,71117,97111,97113,
%U 111111,111113,111117,111119,711111,711113,711117,971111
%N 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 Computed by Jean-Marc Falcoz.
%C Comment from Jean-Marc Falcoz: (Start)
%C The sequence is infinite since it has the following structure:
%C 9713, 11111, 11113, 11117, 11119, 71111, 71113, 71117, 97111,
%C 97113, 111111, 111113, 111117, 111119, 711111, 711113, 711117, 971111,
%C 971113, 1111111, 1111113, 1111117, 1111119, 7111111, 7111113, 7111117, 9711111,
%C 9711113, 11111111, 11111113, 11111117, 11111119, 71111111, 71111113, 71111117, 97111111,
%C 97111113, 111111111, 111111113, 111111117, 111111119, 711111111, 711111113, 711111117, 971111111,
%C 971111113, 1111111111, 1111111113, 1111111117, 1111111119, 7111111111, 7111111113, 7111111117, 9711111111,
%C 9711111113, ... (End)
%H Eric Angelini, <a href="http://www.cetteadressecomportecinquantesignes.com/ConsecDig.htm">Chiffres consecutifs dans quelques suites</a>
%H Eric Angelini, <a href="/A152136/a152136.pdf">Chiffres consecutifs dans quelques suites</a> [Cached copy, with permission]
%o (Python)
%o from itertools import count, islice
%o def cgen(seed, digits, geq="0"): # numbers satisfying the condition
%o allowed = {"1": "1379", "3": "17", "7": "139", "9": "7"}
%o if digits == 1:
%o yield from (c for c in allowed[seed] if c >= geq); return
%o for f in (c for c in allowed[seed] if c >= geq):
%o yield from (f + r for r in cgen(f, digits-1))
%o def nextc(k): # next element of cgen greater than k
%o s = str(k)
%o for d in count(len(s)):
%o geq = s[0] if d == len(s) else "0"
%o for c in map(int, cgen(s[-1], d, geq=geq)):
%o if c > k: return c
%o def agen():
%o an = 1
%o for n in count(1): yield an; an = nextc(an)
%o print(list(islice(agen(), 40))) # _Michael S. Branicky_, Jul 12 2022
%o (Python) # alternate using pattern from comments
%o from itertools import count, islice
%o def agen():
%o yield from [1, 3, 7, 9, 71, 73, 79, 711, 713, 717, 971]
%o for i in count(0):
%o i1 = "1"*i
%o 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 print(list(islice(agen(), 40))) # _Michael S. Branicky_, Jul 12 2022
%Y Cf. A158652, A152604-A152609. See A152136 for another version.
%K nonn,base
%O 1,2
%A _N. J. A. Sloane_, Sep 23 2009