cp's OEIS Frontend

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.

A151963 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the Kaprekar map in A151949.

This page as a plain text file.
%I A151963 #10 Mar 16 2015 23:16:48
%S A151963 1,2,2,2,2,2,2,2,2,2,3,2,3,7,5,6,4,4,6,5,7,3,2,3,7,5,6,4,4,6,5,7,3,2,
%T A151963 3,7,5,6,4,4,6,5,7,3,2,3,7,5,6,4,4,6,5,7,3,2,3,7,5,6,4,4,6,5,7,3,2,3,
%U A151963 7,5,6,4,4,6,5,7,3,2,3,7,5,6,4,4,6,5,7,3,2,3,7,5,6,4,4,6,5,7,3
%N A151963 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the Kaprekar map in A151949.
%C A151963 Equals A151962(n) + 1 iff n < 10001 (when a cycle of length greater than 1 occurs for the first time).
%H A151963 Joseph Myers and Robert G. Wilson v, <a href="/A151963/b151963.txt">Table of n, a(n) for n = 0..1000 </a>.
%H A151963 <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a>
%e A151963 13->18->63->27->45->9->0->0, so a(13)=6+1 = 7.
%p A151963 # Maple program from _R. J. Mathar_:
%p A151963 A151949 := proc(n)
%p A151963 local tup;
%p A151963 tup := sort(convert(n,base,10)) ;
%p A151963 add( (op(i,tup)-op(-i,tup)) *10^(i-1),i=1..nops(tup)) :
%p A151963 end:
%p A151963 A151963 := proc(n)
%p A151963 local tra,x ;
%p A151963 tra := [n] ;
%p A151963 x := n ;
%p A151963 while true do
%p A151963 x := A151949(x) ;
%p A151963 if x in tra then
%p A151963 RETURN(nops(tra)) ;
%p A151963 fi;
%p A151963 tra := [op(tra),x] :
%p A151963 od:
%p A151963 end:
%p A151963 seq(A151963(n),n=0..120) ;
%t A151963 f[n_] := Module[{idn = IntegerDigits@n, idns}, idns = Sort@ idn; FromDigits@ Reverse@ idns - FromDigits@ idns]; g[n_] := Length[ NestWhileList[ f, n, UnsameQ, All]] - 1; Table[g@n, {n, 0, 104}] (* _Robert G. Wilson v_, Aug 20 2009 *)
%Y A151963 In other bases: A164886 (base 2), A164996 (base 3), A165015 (base 4), A165035 (base 5), A165054 (base 6), A165074 (base 7), A165093 (base 8), A165113 (base 9). - _Joseph Myers_, Sep 05 2009
%K A151963 nonn,base
%O A151963 0,2
%A A151963 _N. J. A. Sloane_, Aug 19 2009
%E A151963 Typos corrected by _Joseph Myers_, Aug 20 2009
%E A151963 More terms from _R. J. Mathar_ and _Robert G. Wilson v_, Aug 20 2009