OFFSET
1,2
COMMENTS
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.
LINKS
E. Angelini, n' = (MAXd+MINd)/2
E. Angelini, n' = (MAXd+MINd)/2 [Cached copy, with permission]
EXAMPLE
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.
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.
MATHEMATICA
MAXd(n)={ for(i=1, #n=Vecsmall(Str(n)), if( n[i]>48, for(j=i+1, min(#n, i+n[i]-49),
n[j]>n[i] & n[i]=n[j]), n[i]=32)); eval(Strchr(n)) }
MINd(n)={ for(i=1, #n=Vecsmall(Str(n)), if( n[i]>48, for(j=i+1, min(#n, i+n[i]-49),
n[j]<n[i] & n[i]=n[j]), n[i]=32)); eval(Strchr(n)) }
EA(n)=(MAXd(n)+MINd(n))/2
for(n=1, 99999, EA(n)==n & print1(n", ")) (* Code due to M. F. Hasler, attribution by D. S. McNeil, Nov 24 2010 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Eric Angelini, Nov 24 2010
EXTENSIONS
Edited by D. S. McNeil, Nov 24 2010
STATUS
approved