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.

Showing 1-10 of 10 results.

A164885 Length of preperiodic part of trajectory of n under iteration of the base-2 Kaprekar map in A164884.

Original entry on oeis.org

0, 1, 2, 1, 2, 2, 2, 1, 2, 0, 1, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 0, 1, 1, 1, 1, 1, 2, 1, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1
Offset: 0

Views

Author

Joseph Myers, Aug 29 2009

Keywords

Comments

All base-2 cycles are fixed points, so one less than A164886.

Crossrefs

In other bases: A164995 (base 3), A165014 (base 4), A165034 (base 5), A165053 (base 6), A165073 (base 7), A165092 (base 8), A165112 (base 9), A151962 (base 10).

Extensions

Cross-references edited by Joseph Myers, Sep 04 2009

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

Original entry on oeis.org

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

Views

Author

N. J. A. Sloane, Aug 19 2009

Keywords

Comments

Equals A151962(n) + 1 iff n < 10001 (when a cycle of length greater than 1 occurs for the first time).

Examples

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

Crossrefs

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

Programs

  • Maple
    # Maple program from R. J. Mathar:
    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:
    A151963 := proc(n)
    local tra,x ;
    tra := [n] ;
    x := n ;
    while true do
    x := A151949(x) ;
    if x in tra then
    RETURN(nops(tra)) ;
    fi;
    tra := [op(tra),x] :
    od:
    end:
    seq(A151963(n),n=0..120) ;
  • Mathematica
    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 *)

Extensions

Typos corrected by Joseph Myers, Aug 20 2009
More terms from R. J. Mathar and Robert G. Wilson v, Aug 20 2009

A164995 Length of preperiodic part of trajectory of n under iteration of the base-3 Kaprekar map in A164993.

Original entry on oeis.org

0, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 3, 2, 1, 2, 3, 2, 2, 3, 3, 3, 3, 2, 2, 3, 2, 1, 2, 1, 2, 1, 2, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 0, 2, 1, 2, 2, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 2, 2, 1, 2, 2, 3, 1, 3, 1, 1, 1, 2, 1, 3, 1
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164885 (base 2), A165014 (base 4), A165034 (base 5), A165053 (base 6), A165073 (base 7), A165092 (base 8), A165112 (base 9), A151962 (base 10).

A165014 Length of preperiodic part of trajectory of n under iteration of the base-4 Kaprekar map in A165012.

Original entry on oeis.org

0, 1, 1, 1, 2, 1, 2, 3, 3, 2, 1, 2, 3, 3, 2, 1, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 0, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 2, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 1, 2, 1, 2, 2, 2, 1, 2, 2, 1, 2, 1, 1, 2, 2, 1, 2, 1, 1, 3, 1, 1, 1, 1, 1, 2, 2, 1, 1
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164885 (base 2), A164995 (base 3), A165034 (base 5), A165053 (base 6), A165073 (base 7), A165092 (base 8), A165112 (base 9), A151962 (base 10).

A165034 Length of preperiodic part of trajectory of n under iteration of the base-5 Kaprekar map in A165032.

Original entry on oeis.org

0, 1, 1, 1, 1, 2, 1, 2, 0, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 2, 1, 1, 1, 2, 1, 2, 1, 1, 1, 2, 2, 1, 2, 1, 0, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 2, 1, 2, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164885 (base 2), A164995 (base 3), A165014 (base 4), A165053 (base 6), A165073 (base 7), A165092 (base 8), A165112 (base 9), A151962 (base 10).

A165053 Length of preperiodic part of trajectory of n under iteration of the base-6 Kaprekar map in A165051.

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 2, 1, 2, 4, 3, 3, 4, 2, 1, 2, 4, 3, 3, 4, 2, 1, 2, 4, 3, 3, 4, 2, 1, 2, 4, 3, 3, 4, 2, 1, 2, 2, 3, 1, 2, 3, 2, 1, 2, 3, 1, 2, 3, 2, 2, 3, 1, 2, 1, 3, 3, 3, 1, 2, 2, 1, 1, 1, 1, 2, 3, 2, 2, 2, 2, 2, 3, 3, 3, 1, 2, 3, 3, 2, 2, 3, 1, 2, 3, 2, 1, 2, 3, 1, 1, 3, 2, 2, 3, 1, 2, 1, 3, 3, 3, 1, 3, 2, 1
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164885 (base 2), A164995 (base 3), A165014 (base 4), A165034 (base 5), A165073 (base 7), A165092 (base 8), A165112 (base 9), A151962 (base 10).

A165073 Length of preperiodic part of trajectory of n under iteration of the base-7 Kaprekar map in A165071.

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 1, 2, 1, 2, 3, 4, 2, 4, 3, 2, 1, 2, 3, 4, 2, 4, 3, 2, 1, 2, 3, 4, 2, 4, 3, 2, 1, 2, 3, 4, 2, 4, 3, 2, 1, 2, 3, 4, 2, 4, 3, 2, 1, 2, 2, 3, 1, 1, 2, 3, 2, 1, 2, 3, 1, 1, 2, 3, 2, 2, 3, 1, 1, 2, 1, 3, 3, 3, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 2, 2, 2, 3, 3, 3, 1, 1, 2, 3
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164885 (base 2), A164995 (base 3), A165014 (base 4), A165034 (base 5), A165053 (base 6), A165092 (base 8), A165112 (base 9), A151962 (base 10).

A165092 Length of preperiodic part of trajectory of n under iteration of the base-8 Kaprekar map in A165090.

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 4, 1, 3, 3, 2, 4, 2, 1, 2, 4, 0, 3, 3, 1, 4, 2, 1, 2, 4, 1, 3, 3, 1, 4, 2, 1, 2, 4, 1, 3, 3, 1, 4, 2, 1, 2, 4, 2, 3, 3, 1, 4, 2, 1, 2, 4, 2, 3, 3, 1, 4, 2, 1, 2, 2, 4, 3, 1, 2, 3, 4, 2, 1, 2, 4, 3, 1, 2, 3, 4, 2, 2, 4, 3, 1, 2, 3, 3, 4, 4, 4, 3, 1, 2, 3, 1, 3, 3, 3, 3, 1, 2, 3, 2
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164885 (base 2), A164995 (base 3), A165014 (base 4), A165034 (base 5), A165053 (base 6), A165073 (base 7), A165112 (base 9), A151962 (base 10).

A165112 Length of preperiodic part of trajectory of n under iteration of the base-9 Kaprekar map in A165110.

Original entry on oeis.org

0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 2, 2, 0, 3, 1, 2, 1, 2, 1, 3, 2, 2, 1, 3, 1, 2, 1, 2, 1, 3, 2, 2, 2, 3, 1, 2, 1, 2, 1, 3, 2, 2, 2, 3, 0, 2, 1, 2, 1, 3, 1, 2, 2, 3, 1, 2, 1, 2, 1, 3, 1, 2, 2, 3, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 1, 2, 1, 2, 2, 4, 3, 1, 1, 2, 3, 4, 2, 1, 2, 4, 3, 1, 1, 2, 3, 4, 2, 2, 4, 3, 1
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164885 (base 2), A164995 (base 3), A165014 (base 4), A165034 (base 5), A165053 (base 6), A165073 (base 7), A165092 (base 8), A151962 (base 10).

A343383 Length of the preperiodic part of 'Roll and Subtract' trajectory of n.

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

Views

Author

Jonathon Priestley, Apr 12 2021

Keywords

Comments

'Roll and Subtract' is defined by x -> |x - roll(x)|, where roll(x) takes the first digit of a number and moves it to the back (rolls it around to the back).
Differs from A151962 first at n=101. - R. J. Mathar, May 07 2021

Examples

			a(119) = 4 since |119 - 191| = 72 -> |72 - 27| = 45 -> |45 - 54| = 9 -> |9 - 9| = 0. The value a(0) maps to 0, so the sequence ends there after 4 values have been traversed.
a(12737) = 1 since |12737 - 27371| = 14634 -> |14634 - 46341| = 31707 -> |31707 - 17073| = 14634. Since 14634 is already in the sequence, the sequence ends there.
		

Crossrefs

Cf. A072137 (reverse and subtract).

Programs

  • Mathematica
    Array[Function[w, LengthWhile[w, # != Last[w] &]]@ NestWhileList[Abs[# - FromDigits@ RotateLeft@ IntegerDigits[#]] &, #, Unequal, All] &, 105, 0] (* Michael De Vlieger, Apr 13 2021 *)
  • Python
    def roll(n):
        """ Moves first digit to the back """
        s = str(n)
        return int(s[1:] + s[0])
    def backtrack(past, length, offset, dct):
        """ Goes through every value passed and adds it and it's length to the dictionary """
        if length == 0:
            for elem in past:
                dct[elem] = 0
        i = 0
        while length > 0:
            n = past[i]
            dct[n] = length + offset
            i += 1
            length -= 1
        return dct
    def a(n, dct):
        past = []
        length = 0
        while (n not in dct):
            past.append(n)
            length += 1
            n = abs(n - roll(n))
            if n in past: # For duplicates
                length = past.index(n)
                dct = backtrack(past, length, 0, dct)
                return dct, length
        offset = dct[n]
        dct = backtrack(past, length, offset, dct)
        length += offset
        return dct, length
    dct = {}
    sequence = []
    i = 1
    while i < 1000:
        out = a(i, dct)
        dct = out[0]
        sequence.append(out[1])
        i += 1
Showing 1-10 of 10 results.