[go: up one dir, main page]

login
a(1) = 1; for n > 1, a(n) is the smallest positive integer that has not yet appeared which shares no digit with the sum of all previous terms a(1)..a(n-1).
2

%I #34 Dec 22 2023 08:35:30

%S 1,2,4,3,5,6,7,9,8,10,11,12,13,20,22,24,23,25,14,30,15,17,33,26,16,18,

%T 19,21,27,28,31,29,34,40,41,32,35,36,38,39,37,42,44,50,43,52,45,46,47,

%U 48,49,54,55,57,56,60,53,58,59,62,63,65,70,51,61,64,66,67,69,68,71,73,74,81,90,91,77

%N a(1) = 1; for n > 1, a(n) is the smallest positive integer that has not yet appeared which shares no digit with the sum of all previous terms a(1)..a(n-1).

%C The sequence is finite; after 14594 terms, where a(14594) = 20858, the sum of all terms is 173658294 which contains the digits 1..9, so the next term does not exist.

%C The largest term is a(12742) = 888888.

%H Scott R. Shannon, <a href="/A368181/b368181.txt">Table of n, a(n) for n = 1..14594</a>

%e a(14) = 20 as the sum of all terms a(1)..a(13) = 91, and 20 is the smallest unused number that does not contain the digits 1 or 9.

%o (Python)

%o from itertools import islice

%o def agen():

%o s, aset, mink = 0, {0}, 1

%o while True:

%o k, dset = mink, set(str(s))

%o if dset >= set("123456789"): break

%o while k in aset or set(str(k)) & dset: k += 1

%o an = k; aset.add(an); s += an; yield an

%o while mink in aset: mink += 1

%o print(list(islice(agen(), 80))) # _Michael S. Branicky_, Dec 21 2023

%Y Cf. A362093, A362075, A342383, A342382.

%K nonn,base,fini,full

%O 1,2

%A _Scott R. Shannon_, Dec 21 2023