Digit Product Steps
Take the non-negative integer n. While it has more than one digit, replace it with the product of its digits. Return how many replacements are made before a single digit is left. A number that already has one digit needs 0 replacements.
For example, 39 becomes 3 * 9 = 27, then 2 * 7 = 14, then 1 * 4 = 4, so the answer is 3.
Example 1
n 39
returns 3
39 to 27 to 14 to 4 takes three replacements.
Example 2
n 7
returns 0
7 already has one digit.
Constraints
0 <= n <= 10**9
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.