<<< split from command line arguments >>>

I need help please, i need to write a program that accepts a single integer as a command line argument, validate and the perfoms process described below until it converges and reports how many iterations it took to convrge and what is the converged value.

the process is :

take any three digit number and arrange its digits to descending order and ascending arder and subtract the smaller number from the bigger number. Repeat with the result until the resulting number stops changing (converges). for example

using 132:

321 - 123 = 198

981 - 189 = 792

972 - 279 = 639

963 - 369 = 594

954 - 459 = 495

954 - 459 = 495

you see it brings the same result now (converges)