OFFSET
2,2
LINKS
Joseph Myers, Table of n, a(n) for n=2..1000 [From Joseph Myers, Aug 21 2009]
MAPLE
A151949 := proc(n)
local tup;
tup := sort(convert(n, base, 10)) ;
add( (op(i, tup)-op(-i, tup)) *10^(i-1), i=1..nops(tup)) :
end:
A151957 := proc(n)
local tra, x ;
x := 10^(n-1)+2 ;
tra := [x] ;
while true do
x := A151949(x) ;
if member(x, tra, 'l') then
op(l..nops(tra), tra) ;
RETURN(min(%)) ;
fi;
tra := [op(tra), x] :
od:
end:
seq(A151957(n), n=2..60) ;
# R. J. Mathar, Aug 20 2009
MATHEMATICA
To find the first 20 terms of the trajectory of 10002, for instance:
f[n_]:=Module[{idn=IntegerDigits[n], idns}, idns=Sort[idn]; Abs[FromDigits[ idns]-FromDigits[Reverse[idns]]]]
NestList[f, 10002, 20]
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Harvey P. Dale and N. J. A. Sloane, Aug 18 2009, Aug 19 2009
EXTENSIONS
Extended by R. J. Mathar and Joseph Myers, Aug 20 2009
STATUS
approved