OFFSET
0,11
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
LINKS
Indranil Ghosh, Table of n, a(n) for n = 0..20000 (terms 0..1000 from Joseph Myers and Robert G. Wilson v)
H. Hanslik, E. Hetmaniok, I. Sobstyl, et al., Orbits of the Kaprekar's transformations-some introductory facts, Zeszyty Naukowe Politechniki Śląskiej, Seria: Matematyka Stosowana z. 5, Nr kol. 1945; 2015.
M. Kauers and C. Koutschan, Some D-finite and some possibly D-finite sequences in the OEIS, arXiv:2303.02793 [cs.SC], 2023.
R. J. Mathar, Maple code for A151949 and A151959
Joseph Myers, List of cycles under Kaprekar map (all numbers with <= 60 digits; cycles are represented by their smallest value)
EXAMPLE
For n = 15, a(15) = 51 - 15 = 36. - Indranil Ghosh, Feb 01 2017
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 *)
PROG
(Haskell)
a151949 n = a004186 n - a004185 n
-- Reinhard Zumkeller, corrected: Mar 23 2015, Jul 09 2013
(Python)
def A151949(n):
return int("".join(sorted(str(n), reverse=True)))-int("".join(sorted(str(n)))) # Indranil Ghosh, Feb 01 2017
(PARI) a(n) = {my(d=digits(n)); fromdigits(vecsort(d, , 4)) - fromdigits(vecsort(d)); } \\ Michel Marcus, Dec 08 2019
CROSSREFS
KEYWORD
AUTHOR
N. J. A. Sloane, Aug 18 2009
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
STATUS
approved