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

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

A164886 (Length of preperiodic part) + (length of cycle) of trajectory of n under iteration of the base-2 Kaprekar map in A164884.

Original entry on oeis.org

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

Views

Author

Joseph Myers, Aug 29 2009

Keywords

Comments

All base-2 cycles are fixed points, so one more than A164885.

Crossrefs

In other bases: A164996 (base 3), A165015 (base 4), A165035 (base 5), A165054 (base 6), A165074 (base 7), A165093 (base 8), A165113 (base 9), A151963 (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

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

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 9, 18, 27, 36, 45, 54, 63, 72, 18, 9, 0, 9, 18, 27, 36, 45, 54, 63, 27, 18, 9, 0, 9, 18, 27, 36, 45, 54, 36, 27, 18, 9, 0, 9, 18, 27, 36, 45, 45, 36, 27, 18, 9, 0, 9, 18, 27, 36, 54, 45, 36, 27, 18, 9, 0, 9, 18, 27, 63, 54, 45, 36, 27, 18, 9, 0, 9, 18, 72, 63, 54, 45, 36, 27, 18, 9, 0, 9, 81, 72, 63, 54, 45, 36, 27, 18, 9, 0, 99, 99, 198, 297, 396, 495, 594, 693, 792, 891, 99, 0, 99, 198, 297, 396, 495, 594, 693, 792
Offset: 0

Views

Author

N. J. A. Sloane, Aug 18 2009

Keywords

Comments

Entries are multiples of 9 - see A151950.
a(n) = A004186(n) - A004185(n); a(A010785(n)) = 0. - Reinhard Zumkeller, corrected: Mar 23 2015, Jul 09 2013

Examples

			For n = 15, a(15) = 51 - 15 = 36. - _Indranil Ghosh_, Feb 01 2017
		

Crossrefs

In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A165110 (base 9). - Joseph Myers, Sep 05 2009
Cf. also A004185, A004186, A099009 (fixed points).

Programs

  • Haskell
    a151949 n = a004186 n - a004185 n
    -- Reinhard Zumkeller, corrected: Mar 23 2015, Jul 09 2013
    
  • Mathematica
    f[n_] := Module[{idn = IntegerDigits@n, idns}, idns = Sort@ idn; FromDigits@ Reverse@ idns - FromDigits@ idns]; Table[ f@n, {n, 0, 200}] (* Harvey P. Dale, Aug 18 2009 *)
    Flatten[Table[Differences[FromDigits /@ {y = Sort[x = IntegerDigits[n]], Reverse[y]}], {n, 0, 74}]] (* Jayanta Basu, Jul 11 2013 *)
  • PARI
    a(n) = {my(d=digits(n)); fromdigits(vecsort(d,,4)) - fromdigits(vecsort(d));} \\ Michel Marcus, Dec 08 2019
  • Python
    def A151949(n):
        return int("".join(sorted(str(n),reverse=True)))-int("".join(sorted(str(n)))) # Indranil Ghosh, Feb 01 2017
    

Extensions

More terms from Robert G. Wilson v, Aug 19 2009
More than the usual number of terms are shown in order to distinguish this from similar sequences. - N. J. A. Sloane, Sep 22 2021

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

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

Original entry on oeis.org

0, 0, 0, 0, 3, 0, 3, 6, 6, 3, 0, 3, 9, 6, 3, 0, 15, 15, 30, 45, 15, 0, 15, 30, 30, 15, 15, 30, 45, 30, 30, 30, 30, 30, 30, 45, 30, 15, 15, 30, 30, 15, 0, 15, 45, 30, 15, 15, 45, 45, 45, 45, 45, 30, 30, 30, 45, 30, 15, 15, 45, 30, 15, 0, 63, 75, 138, 201, 75, 63, 126, 189, 138, 126
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Examples

			For n = 11, 11_10 = 23_4. So, a(11) = 32_4 - 23_4 = 14 - 11 = 3. - _Indranil Ghosh_, Feb 02 2017
		

Crossrefs

Cf. A165013.
In other bases: A164884 (base 2), A164993 (base 3), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A165110 (base 9), A151949 (base 10).

Programs

  • Mathematica
    b4km[n_]:=Module[{idn4=Sort[IntegerDigits[n,4]]},FromDigits[ Reverse[ idn4],4]-FromDigits[idn4,4]]; Array[b4km,80,0]
  • PARI
    cons(m) = {local(b, r); r=0; b=1; for(i=1, matsize(m)[2], r=r+b*m[i]; b=b*4); r}
    A165012(n) = {local(m, r); r=[]; m=n; while(m>0, r=concat(m%4, r); m=floor(m/4)); cons(vecsort(r,,0))-cons(vecsort(r,,4))} \\ Michael B. Porter, Nov 05 2009

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

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 5, 0, 5, 10, 15, 20, 10, 5, 0, 5, 10, 15, 15, 10, 5, 0, 5, 10, 20, 15, 10, 5, 0, 5, 25, 20, 15, 10, 5, 0, 35, 35, 70, 105, 140, 175, 35, 0, 35, 70, 105, 140, 70, 35, 35, 70, 105, 140, 105, 70, 70, 70, 105, 140, 140, 105, 105, 105, 105, 140, 175, 140, 140, 140
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Examples

			For n = 10, 10_10 = 14_6. So, a(10) = 41_6 - 14_6 = 25 - 10 = 15. - _Indranil Ghosh_, Feb 02 2017
		

Crossrefs

Cf. A165052.
In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165032 (base 5), A165071 (base 7), A165090 (base 8), A165110 (base 9), A151949 (base 10).

Programs

  • Mathematica
    a[n_] := With[{dd = IntegerDigits[n, 6]}, FromDigits[ReverseSort[dd], 6] - FromDigits[Sort[dd], 6]];
    a /@ Range[0, 100] (* Jean-François Alcover, Jan 08 2020 *)

A165090 a(n) is the image of n under the base-8 Kaprekar map n -> (n with digits sorted into descending order) - (n with digits sorted into ascending order).

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 7, 14, 21, 28, 35, 42, 14, 7, 0, 7, 14, 21, 28, 35, 21, 14, 7, 0, 7, 14, 21, 28, 28, 21, 14, 7, 0, 7, 14, 21, 35, 28, 21, 14, 7, 0, 7, 14, 42, 35, 28, 21, 14, 7, 0, 7, 49, 42, 35, 28, 21, 14, 7, 0, 63, 63, 126, 189, 252, 315, 378, 441, 63, 0, 63, 126, 189
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Examples

			For n = 11, 11_10 = 13_8. So, a(11) = 31_8 - 13_8 = 25 - 11 = 14. - _Indranil Ghosh_, Feb 02 2017
		

Crossrefs

Cf. A165091.
In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165110 (base 9), A151949 (base 10).

Programs

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

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

Original entry on oeis.org

0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 16, 24, 32, 40, 48, 56, 16, 8, 0, 8, 16, 24, 32, 40, 48, 24, 16, 8, 0, 8, 16, 24, 32, 40, 32, 24, 16, 8, 0, 8, 16, 24, 32, 40, 32, 24, 16, 8, 0, 8, 16, 24, 48, 40, 32, 24, 16, 8, 0, 8, 16, 56, 48, 40, 32, 24, 16, 8, 0, 8, 64, 56, 48, 40, 32, 24, 16, 8
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Examples

			For n = 11, 11_10 = 12_9. So, a(11) = 21_9 - 12_9 = 19 - 11 = 8. - _Indranil Ghosh_, Feb 02 2017
		

Crossrefs

Cf. A165111.
In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165032 (base 5), A165051 (base 6), A165071 (base 7), A165090 (base 8), A151949 (base 10).

Programs

  • Mathematica
    a[n_] := With[{dd = IntegerDigits[n, 9]}, FromDigits[ReverseSort[dd], 9] - FromDigits[Sort[dd], 9]];
    a /@ Range[0, 100] (* Jean-François Alcover, Jan 08 2020 *)

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

Original entry on oeis.org

0, 0, 0, 0, 0, 4, 0, 4, 8, 12, 8, 4, 0, 4, 8, 12, 8, 4, 0, 4, 16, 12, 8, 4, 0, 24, 24, 48, 72, 96, 24, 0, 24, 48, 72, 48, 24, 24, 48, 72, 72, 48, 48, 48, 72, 96, 72, 72, 72, 72, 48, 48, 48, 72, 96, 48, 24, 24, 48, 72, 48, 24, 0, 24, 48, 72, 48, 24, 24, 48, 96, 72, 48, 48, 48, 72, 72, 72
Offset: 0

Views

Author

Joseph Myers, Sep 04 2009

Keywords

Examples

			For n = 10, 10_10 = 20_5. So, a(10) = 20_5 - 2_5 = 10 - 2 = 8. - _Indranil Ghosh_, Feb 02 2017
		

Crossrefs

Cf. A165033.
In other bases: A164884 (base 2), A164993 (base 3), A165012 (base 4), A165051 (base 6), A165071 (base 7), A165090 (base 8), A165110 (base 9), A151949 (base 10).

Programs

  • Mathematica
    a[n_] := With[{dd = IntegerDigits[n, 5]}, FromDigits[ReverseSort[dd], 5] - FromDigits[Sort[dd], 5]];
    a /@ Range[0, 100] (* Jean-François Alcover, Jan 08 2020 *)
Showing 1-10 of 21 results. Next