login
a(n) is the smallest positive number not yet in the sequence that if n is even, contains the smallest digit in a(n-1), and if n is odd, contains the largest digit in a(n-1); a(1)=0.
5

%I #43 Jun 13 2018 00:28:47

%S 0,10,1,11,12,13,3,23,30,20,2,21,22,24,4,14,34,31,32,25,5,15,35,33,36,

%T 37,7,17,27,26,6,16,46,40,41,18,8,28,38,39,9,19,29,42,43,53,45,44,47,

%U 48,58,50,51,61,56,52,54,49,59,55,57,65,60,70,67,62,63,73,71,81

%N a(n) is the smallest positive number not yet in the sequence that if n is even, contains the smallest digit in a(n-1), and if n is odd, contains the largest digit in a(n-1); a(1)=0.

%C The 1-digit numbers appear in the sequence in the following order: 0,1,3,2,4,5,7,6,8,9.

%C After the first initial terms, the sequence oscillates about the line y=x.

%C The first differences are bounded by 30 and -30 for the initial terms, then by 20 and -20. After the first 122 terms the sequence is bounded most of the time by 10 and -10, with eventual jumps that seem to remain bounded by 30 and -30.

%C Inverse: 1, 3, 11, 7, 15, 21, 31, 27, 37, 41, 2, 4, 5, 6, 16, 22, 32, 28, 36, 42, 10, 12, 13, 8, 14, 20, ..., . - _Robert G. Wilson v_, Dec 29 2017

%C Also: a(0) = 0 (and 0 counts as a digit). For n > 0, if n is odd respectively even then a(n) is the smallest integer not already in the sequence that contains the smallest respectively largest digit of a(n - 1). - _David A. Corneth_, Dec 29 2017

%H Robert G. Wilson v, <a href="/A297352/b297352.txt">Table of n, a(n) for n = 1..11111</a>

%e a(2)=10 since it is the smallest number not yet in the sequence that contains the smallest digit in a(1)=0; a(3)=1 since it is the smallest number not yet in the sequence that contains the largest digit in a(2)=10.

%t a[n_] := a[n] = Block[{k = 1, s = Union[IntegerDigits[a[n - 1]]][[If[ OddQ@ n, -1, 1]]], t = Array[a, n -1]}, While[ MemberQ[t, k] || !MemberQ[ IntegerDigits@ k, s], k++]; k]; a[1] = 0; Array[a, 70] (* _Robert G. Wilson v_, Dec 29 2017 *)

%Y Cf. A297353.

%K nonn,base

%O 1,2

%A _Enrique Navarrete_, Dec 28 2017

%E Corrected a(65) onward by _Robert G. Wilson v_, Dec 29 2017

%E Definition clarified by _N. J. A. Sloane_, Jan 19 2018 and again Feb 08 2018