This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A151957 #9 Dec 05 2014 04:52:52 %S A151957 0,495,6174,62964,420876,7509843,64308654,753098643,6431088654, %T A151957 86420987532,643330866654,8764209875322,64333308666654, %U A151957 885432098765412,6543331088666544,88543320987665412,975533110888664421 %N A151957 Iterate the Kaprekar map of A151949 starting at the n-digit number 100...02; sequence gives the lowest number in the resulting cycle. %H A151957 Joseph Myers, <a href="/A151957/b151957.txt">Table of n, a(n) for n=2..1000</a> [From _Joseph Myers_, Aug 21 2009] %H A151957 <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a> %p A151957 A151949 := proc(n) %p A151957 local tup; %p A151957 tup := sort(convert(n,base,10)) ; %p A151957 add( (op(i,tup)-op(-i,tup)) *10^(i-1),i=1..nops(tup)) : %p A151957 end: %p A151957 A151957 := proc(n) %p A151957 local tra,x ; %p A151957 x := 10^(n-1)+2 ; %p A151957 tra := [x] ; %p A151957 while true do %p A151957 x := A151949(x) ; %p A151957 if member(x,tra,'l') then %p A151957 op(l..nops(tra),tra) ; %p A151957 RETURN(min(%)) ; %p A151957 fi; %p A151957 tra := [op(tra),x] : %p A151957 od: %p A151957 end: %p A151957 seq(A151957(n),n=2..60) ; %p A151957 # _R. J. Mathar_, Aug 20 2009 %t A151957 To find the first 20 terms of the trajectory of 10002, for instance: %t A151957 f[n_]:=Module[{idn=IntegerDigits[n],idns},idns=Sort[idn];Abs[FromDigits[ idns]-FromDigits[Reverse[idns]]]] %t A151957 NestList[f,10002,20] %Y A151957 See A151958 for the length of the cycles. Cf. A151949, A151955 (the trajectory of 102), A151956 (the trajectory of 1002). %Y A151957 See also A151967, A151968. %K A151957 nonn,base %O A151957 2,2 %A A151957 _Harvey P. Dale_ and _N. J. A. Sloane_, Aug 18 2009, Aug 19 2009 %E A151957 Extended by _R. J. Mathar_ and _Joseph Myers_, Aug 20 2009