login
A336285
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.
6
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, 26, 27, 29, 28, 30, 31, 32, 33, 34, 35, 36, 37, 38, 40, 39, 41, 42, 43, 44, 45, 46, 47, 48, 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
OFFSET
0,3
COMMENTS
In other words, for any n > 0, a(n) + a(n+1) belongs to A010784.
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.
LINKS
Scott R. Shannon, Image of the first 1000000 terms. The green line is a(n) = n.
EXAMPLE
The first terms, alongside a(n) + a(n+1), are:
n a(n) a(n)+a(n+1)
-- ---- -----------
0 0 1
1 1 3
2 2 5
3 3 7
4 4 9
5 5 12
6 7 13
7 6 14
8 8 17
9 9 19
10 10 21
PROG
(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)))
(Python)
def agen():
alst, aset, min_unused = [0], {0}, 1
yield 0
while True:
an = min_unused
while True:
while an in aset: an += 1
t = str(alst[-1] + an)
if len(t) == len(set(t)):
alst.append(an); aset.add(an); yield an
if an == min_unused: min_unused = min(set(range(max(aset)+2))-aset)
break
an += 1
g = agen()
print([next(g) for n in range(77)]) # Michael S. Branicky, Mar 11 2021
KEYWORD
nonn,base,fini,look
AUTHOR
Rémy Sigrist, Jul 22 2020.
EXTENSIONS
a(0)=0 added by N. J. A. Sloane, Mar 14 2021
STATUS
approved