|
|
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).
|
|
52
|
|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,11
|
|
COMMENTS
|
Entries are multiples of 9 - see A151950.
|
|
LINKS
|
|
|
EXAMPLE
|
|
|
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
(Python)
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
|
|
|
EXTENSIONS
|
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
|
|
|
|