login
a(0) = 0; for n > 0, a(n) is the least positive integer not occurring earlier such that both the digits in a(n) and the digits in a(n-1)+a(n) are all distinct.
4

%I #20 Mar 14 2021 10:52:42

%S 0,1,2,3,4,5,7,6,8,9,10,13,12,14,15,16,18,17,19,20,21,24,23,25,26,27,

%T 29,28,30,31,32,35,34,36,37,38,40,39,41,42,43,46,45,47,48,49,53,50,52,

%U 51,54,69,56,64,59,61,62,58,65,60,63,57,67,68,70,72,71,74,73,75,78,76,80,79,81,82,83

%N a(0) = 0; for n > 0, a(n) is the least positive integer not occurring earlier such that both the digits in a(n) and the digits in a(n-1)+a(n) are all distinct.

%C The sequence is finite due to the finite number of positive integers with distinct digits, see A010784, although the exact number of terms is currently unknown.

%H Scott R. Shannon, <a href="/A342383/a342383.png">Image of the first 60000 terms</a>. The green line is a(n) = n.

%e a(1) = 1 as 1 has one distinct digit and a(0)+1 = 0+1 = 1 which has one distinct digit 0.

%e a(6) = 7 as 7 has one distinct digit and a(5)+7 = 5+7 = 12 which has two distinct digits. Note that 6 is the first skipped number as a(5)+6 = 5+6 = 11 has 1 as a duplicate digit.

%e a(11) = 13 as 13 has two distinct digits and a(10)+13 = 10+13 = 23 which has two distinct digits. Note that 11 and 12 are skipped as 11 has 1 as a duplicate digit while a(10)+12 = 10+12 = 22 has 2 as a duplicate digit.

%t Block[{a = {0}, k, m = 10^4}, Do[k = 1; While[Nand[FreeQ[a, k], AllTrue[DigitCount[a[[-1]] + k], # < 2 &], AllTrue[DigitCount[k], # < 2 &]], If[k > m, Break[]]; k++]; If[k > m, Break[]]; AppendTo[a, k], {i, 76}]; a] (* _Michael De Vlieger_, Mar 11 2021 *)

%o (Python)

%o def agen():

%o alst, aset = [0], {0}

%o yield 0

%o while True:

%o an = 1

%o while True:

%o while an in aset: an += 1

%o stran, t = str(an), str(alst[-1] + an)

%o if len(stran) == len(set(stran)) and len(t) == len(set(t)):

%o alst.append(an); aset.add(an); yield an; break

%o an += 1

%o g = agen()

%o print([next(g) for n in range(77)]) # _Michael S. Branicky_, Mar 11 2021

%Y Cf. A336285, A342382, A010784, A043537, A043096, A276633, A002378.

%K nonn,base,fini,look

%O 0,3

%A _Scott R. Shannon_, Mar 09 2021