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.

Original entry on oeis.org

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, 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, 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
Offset: 0

Views

Author

N. J. A. Sloane, Aug 19 2009

Keywords

Examples

			13 -> 18 -> 63 -> 27 -> 45 -> 9 -> 0 -> 0, so a(13)=6.
		

Crossrefs

Cf. A151949, A151963. Strictly different from A072137.
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

Programs

  • 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:
    A151962 := proc(n)
    local tra,x ;
    tra := [n] ;
    x := n ;
    while true do
    x := A151949(x) ;
    if member(x,tra,'l') then
    RETURN(l-1) ;
    fi;
    tra := [op(tra),x] :
    od:
    end:
    seq(A151962(n),n=0..120) ;
    # R. J. Mathar, Aug 20 2009

Extensions

More terms from R. J. Mathar, Aug 20 2009