OFFSET
1,2
COMMENTS
Starting with the terms (1,2) this sequence consists of minimum increasing integer terms such that no term is the concatenation of any two or three previous distinct terms. The next consecutive numbers skipped after 121 are 122 = Concatenate(1,22) and 123 = Concatenate(1,2,3). This is the analog of a 3-Stöhr sequence with concatenation (base 10) substituting for addition. A026474 is a 3-Stöhr sequence.
LINKS
Michael S. Branicky, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Stöhr Sequence.
FORMULA
a(0) = 1, a(1) = 2, for n>2: a(n) = least k > a(n-1) such that k is not an element of {Concatenate[a(h),a(i),a(j)]} or {Concatenate[a(i),a(j)]} for any three distinct a(h), a(i), and a(j), where h, i, j < n.
MATHEMATICA
conc[w_] := Flatten[ (FromDigits /@ Flatten /@ IntegerDigits /@ (Permutations[#]) &) /@ Subsets[w, {2, 3}]]; up = 10^3; L = {1, 2, 3}; cc = conc[L]; Do[k = 1 + Max@L; While[MemberQ[cc, k], k++]; If[k > up, Break[]]; Do[cc = Union[cc, Select[ conc[{k, L[[i]], L[[j]]}], # <= up &]], {i, Length[L]}, {j, i - 1}]; AppendTo[L, k], {60}]; L (* Giovanni Resta, Jun 15 2016 *)
PROG
(Python)
from itertools import islice
def incats(s, L, k):
if s == "": return True
if k == 0: return False
return any(s.startswith(w) and incats(s[len(w):], L[:i]+L[i+1:], k-1) for i, w in enumerate(L))
def agen(): # generator of terms
L, an, s = ["1", "2"], 3, "3"
yield from [1, 2]
while True:
yield an
L.append(s)
while incats((s:=str(an)), L, 3):
an += 1
print(list(islice(agen(), 70))) # Michael S. Branicky, Feb 01 2024
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Jonathan Vos Post, Feb 18 2006
EXTENSIONS
Corrected and edited by Giovanni Resta, Jun 15 2016
STATUS
approved