login

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”).

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.
7
1, 3, 7, 9, 71, 73, 79, 711, 713, 717, 971, 973, 1111, 1113, 1117, 1119, 7111, 7113, 7117, 9711, 9713, 11111, 11113, 11117, 11119, 71111, 71113, 71117, 97111, 97113, 111111, 111113, 111117, 111119, 711111, 711113, 711117, 971111
OFFSET
1,2
COMMENTS
Computed by Jean-Marc Falcoz.
Comment from Jean-Marc Falcoz: (Start)
The sequence is infinite since it has the following structure:
9713, 11111, 11113, 11117, 11119, 71111, 71113, 71117, 97111,
97113, 111111, 111113, 111117, 111119, 711111, 711113, 711117, 971111,
971113, 1111111, 1111113, 1111117, 1111119, 7111111, 7111113, 7111117, 9711111,
9711113, 11111111, 11111113, 11111117, 11111119, 71111111, 71111113, 71111117, 97111111,
97111113, 111111111, 111111113, 111111117, 111111119, 711111111, 711111113, 711111117, 971111111,
971111113, 1111111111, 1111111113, 1111111117, 1111111119, 7111111111, 7111111113, 7111111117, 9711111111,
9711111113, ... (End)
PROG
(Python)
from itertools import count, islice
def cgen(seed, digits, geq="0"): # numbers satisfying the condition
allowed = {"1": "1379", "3": "17", "7": "139", "9": "7"}
if digits == 1:
yield from (c for c in allowed[seed] if c >= geq); return
for f in (c for c in allowed[seed] if c >= geq):
yield from (f + r for r in cgen(f, digits-1))
def nextc(k): # next element of cgen greater than k
s = str(k)
for d in count(len(s)):
geq = s[0] if d == len(s) else "0"
for c in map(int, cgen(s[-1], d, geq=geq)):
if c > k: return c
def agen():
an = 1
for n in count(1): yield an; an = nextc(an)
print(list(islice(agen(), 40))) # Michael S. Branicky, Jul 12 2022
(Python) # alternate using pattern from comments
from itertools import count, islice
def agen():
yield from [1, 3, 7, 9, 71, 73, 79, 711, 713, 717, 971]
for i in count(0):
i1 = "1"*i
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))
print(list(islice(agen(), 40))) # Michael S. Branicky, Jul 12 2022
CROSSREFS
Cf. A158652, A152604-A152609. See A152136 for another version.
Sequence in context: A087147 A363572 A337613 * A118559 A189244 A127789
KEYWORD
nonn,base
AUTHOR
N. J. A. Sloane, Sep 23 2009
STATUS
approved