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.

A151962 Length of preperiodic part of trajectory of n under iteration of the Kaprekar map in A151949.

This page as a plain text file.
%I A151962 #9 Mar 16 2019 02:24:45
%S A151962 0,1,1,1,1,1,1,1,1,1,2,1,2,6,4,5,3,3,5,4,6,2,1,2,6,4,5,3,3,5,4,6,2,1,
%T A151962 2,6,4,5,3,3,5,4,6,2,1,2,6,4,5,3,3,5,4,6,2,1,2,6,4,5,3,3,5,4,6,2,1,2,
%U A151962 6,4,5,3,3,5,4,6,2,1,2,6,4,5,3,3,5,4,6,2,1,2,6,4,5,3,3,5,4,6,2
%N A151962 Length of preperiodic part of trajectory of n under iteration of the Kaprekar map in A151949.
%H A151962 Joseph Myers, <a href="/A151962/b151962.txt">Table of n, a(n) for n = 0..1000</a>
%H A151962 <a href="/index/K#Kaprekar_map">Index entries for the Kaprekar map</a>
%e A151962 13 -> 18 -> 63 -> 27 -> 45 -> 9 -> 0 -> 0, so a(13)=6.
%p A151962 A151949 := proc(n)
%p A151962 local tup;
%p A151962 tup := sort(convert(n,base,10)) ;
%p A151962 add( (op(i,tup)-op(-i,tup)) *10^(i-1),i=1..nops(tup)) :
%p A151962 end:
%p A151962 A151962 := proc(n)
%p A151962 local tra,x ;
%p A151962 tra := [n] ;
%p A151962 x := n ;
%p A151962 while true do
%p A151962 x := A151949(x) ;
%p A151962 if member(x,tra,'l') then
%p A151962 RETURN(l-1) ;
%p A151962 fi;
%p A151962 tra := [op(tra),x] :
%p A151962 od:
%p A151962 end:
%p A151962 seq(A151962(n),n=0..120) ;
%p A151962 # _R. J. Mathar_, Aug 20 2009
%Y A151962 Cf. A151949, A151963. Strictly different from A072137.
%Y A151962 In other bases: A164885 (base 2), A164995 (base 3), A165014 (base 4), A165034 (base 5), A165053 (base 6), A165073 (base 7), A165092 (base 8), A165112 (base 9). - _Joseph Myers_, Sep 05 2009
%K A151962 nonn,base
%O A151962 0,11
%A A151962 _N. J. A. Sloane_, Aug 19 2009
%E A151962 More terms from _R. J. Mathar_, Aug 20 2009