|
|
A151957
|
|
Iterate the Kaprekar map of A151949 starting at the n-digit number 100...02; sequence gives the lowest number in the resulting cycle.
|
|
5
|
|
|
0, 495, 6174, 62964, 420876, 7509843, 64308654, 753098643, 6431088654, 86420987532, 643330866654, 8764209875322, 64333308666654, 885432098765412, 6543331088666544, 88543320987665412, 975533110888664421
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
2,2
|
|
LINKS
|
|
|
MAPLE
|
local tup;
tup := sort(convert(n, base, 10)) ;
add( (op(i, tup)-op(-i, tup)) *10^(i-1), i=1..nops(tup)) :
end:
local tra, x ;
x := 10^(n-1)+2 ;
tra := [x] ;
while true do
if member(x, tra, 'l') then
op(l..nops(tra), tra) ;
RETURN(min(%)) ;
fi;
tra := [op(tra), x] :
od:
end:
|
|
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
|
|
|
EXTENSIONS
|
|
|
STATUS
|
approved
|
|
|
|