Question: Kaprekar's Routine Help MAple PROC

Need help creating a proc() for Kaprekar's routine. Ive been able to convert a number (x,n) to ascending/descending order and then defining f to be the sum of them subtracted, but i cant figure out how to put it into a proc so that it continues to loop until kaprekar's number 6174 is reached and stop.

If you have any idea please advise! thanks

Please Wait...