login
Lexicographically earliest sequence of distinct nonnegative terms such that the last digit of a(n) is present in a(n+1).
6

%I #19 Feb 18 2024 12:14:49

%S 0,10,20,30,40,50,60,70,80,90,100,101,1,11,12,2,21,13,3,23,31,14,4,24,

%T 34,41,15,5,25,35,45,51,16,6,26,36,46,56,61,17,7,27,37,47,57,67,71,18,

%U 8,28,38,48,58,68,78,81,19,9,29,39,49,59,69,79,89,91,102,22,32,42,52,62,72,82,92,112,120,103,33

%N Lexicographically earliest sequence of distinct nonnegative terms such that the last digit of a(n) is present in a(n+1).

%C This is not A156819.

%H Michael S. Branicky, <a href="/A370400/b370400.txt">Table of n, a(n) for n = 1..10000</a>

%H Eric Angelini, <a href="https://cinquantesignes.blogspot.com/2024/02/talking-to-me.html">Talking to me?</a>, personal blog, Feb 2024.

%e a(12) = 101 and the rightmost digit "1" is present in the next term ( 1)

%e a(13) = 1 and the rightmost digit "1" is present in the next term (11)

%e a(14) = 11 and the rightmost digit "1" is present in the next term (12)

%e a(15) = 12 and the rightmost digit "2" is present in the next term ( 2)

%e a(16) = 2 and the rightmost digit "2" is present in the next term (21)

%e a(17) = 21 and the rightmost digit "1" is present in the next term (13), etc.

%t a[1]=0;a[n_]:=a[n]=(k=1;While[MemberQ[Array[a,n-1],k]|| FreeQ[IntegerDigits@k,Mod[a[n-1],10]],k++];k);Array[a,79]

%o (Python)

%o from itertools import count, islice

%o def agen(): # generator of terms

%o an, aset, mink = 0, set(), 1

%o while True:

%o yield an

%o aset.add(an)

%o t, k = str(an%10), mink

%o an = next(k for k in count(mink) if k not in aset and t in str(k))

%o while mink in aset: mink += 1

%o print(list(islice(agen(), 79))) # _Michael S. Branicky_, Feb 18 2024

%Y Cf. A370401, A370402, A370403, A370404, A370405, A156819.

%K base,nonn

%O 1,2

%A _Eric Angelini_ and _Giorgos Kalogeropoulos_, Feb 17 2024