If someone ever told you that the answer to the ultimate question of life, the universe and everything is "42", tell them that is wrong. The answer is "6174" and here's why (and prepare to get your mind blown):
Take any number with 4 non-repeating digits. Say 1562.
Step 1: Arrange the number in ascending and then descending order
Step 2: Subtract the smaller number from the bigger number
6521 - 1256 = 5265
Repeat the steps:
6552 - 2556 = 3996
9963 - 3699 = 6264
6642 - 2466 = 4176
7641 - 1467 = 6174
Try any 4-digit number with non-repeating digits, and you'll *always* get 6174.
Pretty cool, huh?
6174 is known as Kaprekar's constant. The math operation above, discovered by Indian mathematician D.R. Kaprekar, will reach 6174 after at most 7 steps (if you did more than 7 iterations, check your arithmetics).
See also: Math T-shirts at the NeatoShop
7072 --> 7432 --> 5074 --> 7072...
or
7252 --> 5254 --> 3076 --> 7252...
(there may be more...these are the only ones I've found so far).
the sum of the digits in the answer always add up to nine
3x9= 27 2+7 =9
123x9= 1107 1+1+0+7 =9
Here's the maths for yours either way:
5834 is 8543-3458=5085
5085 is 8550-0558=7992
7992 is 9972-2799=7173
7173 is 7731-1377=6354
6354 is 6543-3456=3087
3087 is 8730-0378=8352
8352 is 8532-2358=(you know it) 6174.