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 12 results. Next

A163205 The non-repetitive Kaprekar binary numbers in decimal.

Original entry on oeis.org

0, 9, 21, 45, 49, 93, 105, 189, 217, 225, 381, 441, 465, 765, 889, 945, 961, 1533, 1785, 1905, 1953, 3069, 3577, 3825, 3937, 3969, 6141, 7161, 7665, 7905, 8001, 12285, 14329, 15345, 15841, 16065, 16129, 24573, 28665, 30705, 31713, 32193, 32385
Offset: 1

Views

Author

Damir Olejar, Jul 23 2009

Keywords

Comments

Same as A160761, but with no repetitions. The numbers also exist in A143088, except that every first and last number is omitted from A143088's pyramid.
From Joseph Myers, Aug 29 2009: (Start)
Note that all base-2 cycles are fixed points.
Initial terms in base 2: 0, 1001, 10101, 101101, 110001, 1011101, 1101001, 10111101, 11011001, 11100001. (End)

Examples

			The number 9 is 1001 in binary. The maximum number using the same number of 0's and 1's is found and the minimum number having the same number of 0's and 1's is found to obtain the equation such as 1100 - 0011 = 1001. Repeating the same procedure gives us the same number and pattern of 0's and 1's. Therefore 9 is one of the Kaprekar numbers. If 9 did not occur before, it is counted as a number that belongs to a sequence and added to a database to skip repetitions. Numbers that end the procedure in 0 are excluded since they are not Kaprekar numbers. A number 9 can also be obtained with, let's say, 1100. Since number 9 already occurred for 1001, the number 9 occurring for 1100 is ignored to avoid repetition.
		

References

  • M. Charosh, Some Applications of Casting Out 999...'s, Journal of Recreational Mathematics 14, 1981-82, pp. 111-118.
  • D. R. Kaprekar, On Kaprekar numbers, J. Rec. Math., 13 (1980-1981), pp. 81-82.

Crossrefs

In other bases: A164997 (base 3), A165016 (base 4), A165036 (base 5), A165055 (base 6), A165075 (base 7), A165094 (base 8), A165114 (base 9), A099009 (base 10).

Programs

  • Java
    import java.util.*; class pattern { public static void main(String args[]) { int mem1 = 0; int mem2 =1; ArrayList memory = new ArrayList(); for (int i = 1; i
    				
  • Mathematica
    nmax = 10^5; f[n_] := Module[{id, sid, min, max}, id = IntegerDigits[n, 2]; min = FromDigits[sid = Sort[id], 2]; max = FromDigits[Reverse[sid], 2]; max - min]; Reap[Do[If[(fpn = FixedPoint[f, n]) > 0, Sow[fpn]], {n, 0, nmax}]][[2, 1]] // Union // Prepend[#, 0]& (* Jean-François Alcover, Apr 23 2017 *)

Formula

1. Sort all integers from the number in descending order.
2. Sort all integers from the number in ascending order.
3. Subtract ascending from descending order to obtain a new number.
4. Repeat the steps 1-3 with a new number until a repetitive sequence is obtained or until a zero is obtained.
5. Call the repetitive sequence's number a Kaprekar number, ignore zeros and repetitions from the set of the final results.

Extensions

Initial zero added for consistency with other bases by Joseph Myers, Aug 29 2009

A164884 a(n) = image of n under the base-2 Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order).

Original entry on oeis.org

0, 0, 1, 0, 3, 3, 3, 0, 7, 9, 9, 7, 9, 7, 7, 0, 15, 21, 21, 21, 21, 21, 21, 15, 21, 21, 21, 15, 21, 15, 15, 0, 31, 45, 45, 49, 45, 49, 49, 45, 45, 49, 49, 45, 49, 45, 45, 31, 45, 49, 49, 45, 49, 45, 45, 31, 49, 45, 45, 31, 45, 31, 31, 0, 63, 93, 93, 105, 93, 105, 105, 105, 93, 105, 105
Offset: 0

Views

Author

Joseph Myers, Aug 29 2009

Keywords

Examples

			For n = 17, 17_10 = 10001_2. So, a(17) = 11000_2 - 11_2 = 24 - 3 = 21. - _Indranil Ghosh_, Feb 01 2017
		

Crossrefs

In other bases: A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A165110 (base 9), A151949 (base 10).

Programs

  • Mathematica
    a[n_] := With[{dd = IntegerDigits[n, 2]}, FromDigits[ReverseSort[dd], 2] - FromDigits[Sort[dd], 2]];
    a /@ Range[0, 100] (* Jean-François Alcover, Jan 08 2020 *)
  • Python
    def A164884(n):
        return int("".join(sorted(bin(n)[2:],reverse=True)),2)-int("".join(sorted(bin(n)[2:])),2) # Indranil Ghosh, Feb 01 2017

Extensions

Cross-references edited by Joseph Myers, Sep 04 2009

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

A164887 a(n) = smallest number that leads to a new fixed point under the base-2 Kaprekar map of A164884.

Original entry on oeis.org

0, 9, 17, 33, 35, 65, 67, 129, 131, 135, 257, 259, 263, 513, 515, 519, 527, 1025, 1027, 1031, 1039, 2049, 2051, 2055, 2063, 2079, 4097, 4099, 4103, 4111, 4127, 8193, 8195, 8199, 8207, 8223, 8255, 16385, 16387, 16391, 16399, 16415, 16447, 32769, 32771
Offset: 1

Views

Author

Joseph Myers, Aug 29 2009

Keywords

Comments

Note that all base-2 cycles are fixed points.
Initial terms in base 2: 0,1001,10001,100001,100011,1000001,1000011,10000001,10000011,10000111.
The corresponding fixed points appear in ascending numerical order (i.e., A163205).

Crossrefs

In other bases: A165009 (base 3), A165029 (base 4), A165048 (base 5), A165068 (base 6), A165087 (base 7), A165107 (base 8), A165127 (base 9), A151964 (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

A164996 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the base-3 Kaprekar map in A164993.

Original entry on oeis.org

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

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164886 (base 2), A165015 (base 4), A165035 (base 5), A165054 (base 6), A165074 (base 7), A165093 (base 8), A165113 (base 9), A151963 (base 10).

A165015 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the base-4 Kaprekar map in A165012.

Original entry on oeis.org

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

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164886 (base 2), A164996 (base 3), A165035 (base 5), A165054 (base 6), A165074 (base 7), A165093 (base 8), A165113 (base 9), A151963 (base 10).

A165035 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the base-5 Kaprekar map in A165032.

Original entry on oeis.org

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

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164886 (base 2), A164996 (base 3), A165015 (base 4), A165054 (base 6), A165074 (base 7), A165093 (base 8), A165113 (base 9), A151963 (base 10).

A165054 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the base-6 Kaprekar map in A165051.

Original entry on oeis.org

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

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164886 (base 2), A164996 (base 3), A165015 (base 4), A165035 (base 5), A165074 (base 7), A165093 (base 8), A165113 (base 9), A151963 (base 10).

A165074 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the base-7 Kaprekar map in A165071.

Original entry on oeis.org

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

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Crossrefs

In other bases: A164886 (base 2), A164996 (base 3), A165015 (base 4), A165035 (base 5), A165054 (base 6), A165093 (base 8), A165113 (base 9), A151963 (base 10).
Showing 1-10 of 12 results. Next