cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A341909 a(0) = 0; for n > 0, a(n) is the smallest positive integer not yet in the sequence such that the first digit of a(n) differs by 1 from the last digit of a(n-1).

This page as a plain text file.
%I A341909 #18 Apr 13 2022 01:14:50
%S A341909 0,1,2,3,4,5,6,7,8,9,80,10,11,20,12,13,21,22,14,30,15,40,16,50,17,60,
%T A341909 18,70,19,81,23,24,31,25,41,26,51,27,61,28,71,29,82,32,33,42,34,35,43,
%U A341909 44,36,52,37,62,38,72,39,83,45,46,53,47,63,48,73,49,84,54,55,64,56,57,65,66,58,74,59
%N A341909 a(0) = 0; for n > 0, a(n) is the smallest positive integer not yet in the sequence such that the first digit of a(n) differs by 1 from the last digit of a(n-1).
%H A341909 Michael De Vlieger, <a href="/A341909/b341909.txt">Table of n, a(n) for n = 0..10000</a>
%e A341909 a(10) = 80 as the last digit of a(9) = 9 is 9, thus the first digit of a(10) must be 8. As 8 has already been used the next smallest number starting with 8 is 80.
%e A341909 a(16) = 21 as the last digit of a(15) = 13 is 3, thus the first digit of a(16) must be 2 or 4. As 2, 4 and 20 have already been used the next smallest number starting with 2 is 21.
%t A341909 Block[{a = {0}, k}, Do[k = 1; While[Nand[FreeQ[a, k], Abs[First@ IntegerDigits[k] - Mod[a[[-1]], 10]] == 1], k++]; AppendTo[a, k], {i, 76}]; a] (* _Michael De Vlieger_, Feb 23 2021 *)
%o A341909 (Python)
%o A341909 def nextd(strn, d):
%o A341909   n = int(strn) if strn != "" else 0
%o A341909   return n+1 if str(n+1)[0] == str(d) else int(str(d)+'0'*len(strn))
%o A341909 def aupton(term):
%o A341909   alst, aset = [0], {0}
%o A341909   lastdstr = ["" for d in range(10)]
%o A341909   for n in range(1, term+1):
%o A341909     lastdig = alst[-1]%10
%o A341909     firstdigs = set([max(lastdig-1, 0), min(lastdig+1, 9)]) - {0}
%o A341909     cands = [nextd(lastdstr[d], d) for d in firstdigs]
%o A341909     m = min(cands)
%o A341909     argmin = cands.index(m)
%o A341909     alst.append(m)
%o A341909     strm = str(m)
%o A341909     lastdstr[int(strm[0])] = strm
%o A341909   return alst
%o A341909 print(aupton(76)) # _Michael S. Branicky_, Feb 23 2021
%Y A341909 Cf. A001477, A000027, A341692, A341002, A331163, A331375.
%Y A341909 Cf. A131835, A217394, A217395, A217397, A217398, A217399, A217400, A217401, A217402.
%K A341909 nonn,base
%O A341909 0,3
%A A341909 _Scott R. Shannon_, Feb 23 2021