login
A380298
Lexicographically earliest sequence of positive integers such that any value in the sequence, say v, appears at most twice, and in case v appears twice, then the decimal expansion of v appears in the concatenation of the values surrounded by the two occurrences of v.
2
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 1, 11, 12, 2, 13, 3, 14, 4, 15, 5, 16, 6, 17, 7, 18, 8, 19, 9, 20, 21, 22, 12, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 13, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 14, 43, 44, 34, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 15
OFFSET
1,2
COMMENTS
Every positive integer appears twice in the present sequence:
- we can always extend the sequence with a value not yet in the sequence,
- for any n > 1, a(n) is at most one plus the greatest value so far,
- every integer appears at least once in the sequence (for any v > 0, v necessarily appears at least once among the 2*v-1 initial terms),
- for any v > 0, the first occurrence of v appears before the first occurrence of v+1,
- every integer appears twice in the sequence: for any v > 0, the value 10*v appears after the first occurrence of v, so eventually v must appear a second time.
LINKS
Rémy Sigrist, Perl program
PROG
(Perl) # See Links section.
(Python)
from itertools import count, islice
def agen(): # generator of terms
adict, an, m, s, sn = dict(), 1, 1, "", [None]
for n in count(1):
yield an
s += str(an)
sn.append(len(s))
adict[an] = [n] if an not in adict else adict[an] + [n]
an = next(k for k in count(m) if k not in adict or (len(adict[k])==1 and str(k) in s[sn[adict[k][0]]:]))
while m in adict and len(adict[m]) > 1: m += 1
print(list(islice(agen(), 70))) # Michael S. Branicky, Jan 19 2025
CROSSREFS
See A380300 for a similar sequence.
Sequence in context: A373211 A346393 A389875 * A360074 A392597 A280505
KEYWORD
nonn,base
AUTHOR
Rémy Sigrist, Jan 19 2025
STATUS
approved