%I #51 Mar 16 2021 04:32:12
%S 0,1,2,3,4,5,7,6,8,9,10,11,12,13,14,15,16,18,17,19,20,21,22,23,24,25,
%T 26,27,29,28,30,31,32,33,34,35,36,37,38,40,39,41,42,43,44,45,46,47,48,
%U 49,53,50,52,51,54,55,65,58,62,61,59,64,56,67,57,63,60,66,68,69,70,72,71,74,73,75,77
%N a(0) = 0; for n > 0, a(n) is the least positive integer not occurring earlier such that the digits in a(n-1)+a(n) are all distinct.
%C In other words, for any n > 0, a(n) + a(n+1) belongs to A010784.
%C The sequence is finite since there are only a finite number of positive integers with distinct digits, see A010784, although the exact number of terms is currently unknown.
%H Rémy Sigrist, <a href="/A336285/b336285.txt">Table of n, a(n) for n = 0..10000</a>
%H Scott R. Shannon, <a href="/A342408/a342408.png">Image of the first 1000000 terms</a>. The green line is a(n) = n.
%e The first terms, alongside a(n) + a(n+1), are:
%e n a(n) a(n)+a(n+1)
%e -- ---- -----------
%e 0 0 1
%e 1 1 3
%e 2 2 5
%e 3 3 7
%e 4 4 9
%e 5 5 12
%e 6 7 13
%e 7 6 14
%e 8 8 17
%e 9 9 19
%e 10 10 21
%o (PARI) s=0; v=1; for (n=1, 67, print1 (v", "); s+=2^v; for (w=1, oo, if (!bittest(s, w) && #(d=digits(v+w))==#Set(d), v=w; break)))
%o (Python)
%o def agen():
%o alst, aset, min_unused = [0], {0}, 1
%o yield 0
%o while True:
%o an = min_unused
%o while True:
%o while an in aset: an += 1
%o t = str(alst[-1] + an)
%o if len(t) == len(set(t)):
%o alst.append(an); aset.add(an); yield an
%o if an == min_unused: min_unused = min(set(range(max(aset)+2))-aset)
%o break
%o an += 1
%o g = agen()
%o print([next(g) for n in range(77)]) # _Michael S. Branicky_, Mar 11 2021
%Y Cf. A342383, A338466, A322845, A010784, A043537, A043096, A276633, A002378.
%K nonn,base,fini,look
%O 0,3
%A _Rémy Sigrist_, Jul 22 2020.
%E a(0)=0 added by _N. J. A. Sloane_, Mar 14 2021
|