reviewed
approved
reviewed
approved
proposed
reviewed
editing
proposed
Comment from Jean-Marc Falcoz: (Start) The sequence is infinite since it has the following structure:
The sequence is infinite since it has the following structure:
9711111113, ... (End)
E. Eric Angelini, <a href="/A152136/a152136.pdf">Chiffres consecutifs dans quelques suites</a> [Cached copy, with permission]
print(list(islice(agen(), 440))) # Michael S. Branicky, Jul 12 2022
proposed
editing
editing
proposed
def cgen(seed, digits, geq="0"): # generator of numbers satisfying the condition
if digits == 1: yield from allowed[seed]; return
yield from (c for c in allowed[seed] if c >= geq); return
for f in (c for c in allowed[seed]: yield from (f + r for r in cgen(f, digits-1) if c >= geq):
yield from (f + r for r in cgen(f, digits-1))
def nextc(k): # next element of cgen greater than k
geq = s[0] if d == len(s) else "0"
for c in map(int, cgen(s[-1], d, geq=geq)):
print(list(islice(agen(), 404))) # Michael S. Branicky, Jul 12 2022
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))
(Python)
from itertools import count, islice
def cgen(seed, digits): # generator of numbers satisfying the condition
allowed = {"1": "1379", "3": "17", "7": "139", "9": "7"}
if digits == 1: yield from allowed[seed]; return
for f in allowed[seed]: yield from (f + r for r in cgen(f, digits-1))
def nextc(k): # next element of greater than k
s = str(k)
for d in count(len(s)):
for c in map(int, cgen(s[-1], d)):
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
approved
editing
editing
approved
E. Angelini, <a href="/A152136/a152136.pdf">Chiffres consecutifs dans quelques suites</a> [Cached copy, with permission]
approved
editing