Consider a positive integer
N written in base
b. A sequence is generated from this number by finding the largest digit
d in the expansion of
N and writing
N in base
d+1, repeating until the base the number is written in can be decreased no further. For example, the sequence generated by
346 (10) in starting base 16 has length 6:
15A (16) = 295 (11) = 346 (10) = 1003 (7) = 11122 (4) = 110211 (3). Note that the next term in the sequence would be in base 3 again, which is invalid since the base does not decrease.
The goal of this code golf challenge is to write a program/function that takes two inputs (a decimal integer and a starting base - order doesn't matter and the two numbers must be integers) and outputs the length of the sequence generated according to the above rules.
Some test cases:
(24, 4) = 2 (19, 10) = 1 (346, 16) = 6 (7557, 97) = 20