The best base is 10... Let's reach it! Input:

A positive integer n consisting of digits in the range 0-9.

Challenge:

If d is the highest digit in the integer, assume the base of the number is d+1. E.g. if the integer is 1256 then you shall assume it's in base-7, if it's 10110 then you shall assume it's base-2 (binary), and if it's 159 then it's decimal.

Now, do the following until you either, 1: reach a base-10 integer, or 2: reach a single digit integer.


Convert the integer from base-(d+1) to base-10
Find the base of this new integer (again, base-(d+1) where d is the highest digit in the new number)
Go to step 1.




Examples:

Assume the input is n = 413574. The highest digit d=7, so this is base-8 (octal). Convert this to decimal and get 137084. The highest digit d=8, so this is base-9. Convert this to decimal and get 83911. The highest digit is 9, so this is a decimal number and we stop. The output shall be 83911.

Assume the input is n = 13552. The highest digit is d=5, so this is base-6. Convert this to decimal and get 2156. The highest digit d=6, so this is base-7. Convert this to decimal and get 776. The highest digit is d=7, so this is base-8. Convert this to decimal and get 510. The highest digit is d=5 so this is base-6. Convert this to decimal and get 186. The highest digit is 8, so this is base-9. Convert this to decimal and get 159. The highest digit is 9, so this is a decimal number and we stop. The output shall be 159.

Assume the input is n=17. This will give us 15, then 11, then 3, which we will output since it's a single digit.



Test cases:

5
5

17
3

999
999

87654321  (base-9 -&gt; 42374116 in decimal -&gt; base-7 -&gt; 90419978 in decimal) 
9041998

41253  (5505 -&gt; 1265 -&gt; 488 -&gt; 404 -&gt; 104 -&gt; 29)
29




Notes:


Standard rules regarding I/O, loopholes etc. You may take the input as a string 
Explanations are encouraged
You may use builtin base-conversion commands


Solutions that don't use the language's builtin base-conversion functions (if they exist) are welcome, even if they end up being much longer than the obvious approach using builtin functions. 





Apparently, this is OEIS A091047.
Mathematica, 56 bytes

#//.x_/;(b=Max[d=IntegerDigits@x]+1)&lt;11:&gt;d~FromDigits~b&amp;


Try it online! (Using Mathics.)

I thought I'd check out what the sequence looks like:



And here is a plot of the number of steps it takes to find the result:



(Click for larger versions. See the revision history for plots only up to n = 1000.)

Looks like a very interesting mixture of large scale structure and fine scale chaos. I wonder what's up with the wider gaps around 30,000 and 60,000.