input a 4-digit number where not all numbers are equal. Build the lowesr number from this 4 digits and build the highest number.
build the difference.
the difference is the new number.
goon until number does not change.
output that number.
all languages welcome