%I #26 Feb 27 2020 22:46:26
%S 1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,22,33,44,55,66,77,88,99,
%T 111,112,113,114,115,116,117,118,119,122,133,144,155,166,177,188,199,
%U 222,315,333,417,444,519,555,666,777,888,999,1111,1112,1113,1114
%N Fixed points of the operation x->(max_d(x)+min_d(x))/2, where max_d(x) iteratively replaces each digit d of x from left to right with the largest of the d digits to its right (itself included), and similarly for min_d.
%C Note that for most x, min_d(x) + max_d(x) is even; multiples of 10 whose least significant nonzero digit is 3,5,7, or 9 appear to be exceptions.
%H E. Angelini, <a href="http://www.cetteadressecomportecinquantesignes.com/MAXdMINd.htm">n' = (MAXd+MINd)/2</a>
%H E. Angelini, <a href="/A173646/a173646.pdf">n' = (MAXd+MINd)/2</a> [Cached copy, with permission]
%e The max_d and min_d operations work as follows. Consider max_d(x) for x=723810; we read x from left to right, digit by digit. We replace the 7 with the biggest of the 7 digits on its right (including itself), which is 8, producing 823810. We replace the 2 with the biggest of the 2 digits on its right (including itself), so 2 is replaced by 3, producing 833810. Applying the same rule to the third-digit 3 gives 838810; to the 8 gives 838810 (no change); the 1 is replaced by itself, again giving 838810; and then the 0 is replaced by the largest of the 0 digits to its right (including itself), but since there are none the 0 is replaced by nothing, giving 83881. Therefore max_d(723810) = 83881. min_d(x) works in similar fashion, but replacing each digit with the smallest digit to its right including itself.
%e The sequence consists of those x such that x = (min_d(x) + max_d(x))/2, such as 1519, where 1519 = (1119+1919)/2 = 3038/2 = 1519.
%t MAXd(n)={ for(i=1,#n=Vecsmall(Str(n)), if( n[i]>48, for(j=i+1,min(#n,i+n[i]-49),
%t n[j]>n[i] & n[i]=n[j]), n[i]=32)); eval(Strchr(n)) }
%t MINd(n)={ for(i=1,#n=Vecsmall(Str(n)), if( n[i]>48, for(j=i+1,min(#n,i+n[i]-49),
%t n[j]<n[i] & n[i]=n[j]), n[i]=32)); eval(Strchr(n)) }
%t EA(n)=(MAXd(n)+MINd(n))/2
%t for(n=1,99999,EA(n)==n & print1(n", ")) (* Code due to _M. F. Hasler_, attribution by _D. S. McNeil_, Nov 24 2010 *)
%K nonn,base
%O 1,2
%A _Eric Angelini_, Nov 24 2010
%E Edited by _D. S. McNeil_, Nov 24 2010
|