Digit Product Chain
Easy
math
digit-manipulation
simulation
iteration
Problem Description
Starting from a given number, repeatedly multiply all its digits until you get a single-digit result. Count how many multiplication steps are needed to reach the single-digit number.
Input Format
A single positive integer.
Output Format
Number of steps needed to reach a single-digit result.
Constraints
• 1 ≤ input ≤ 10^9
• Single-digit numbers require 0 steps
• If any digit is 0, product becomes 0 (single digit)
• Count each multiplication as one step
• Handle large initial numbers
Sample Input/Output
Input:
39
Output:
3
Explanation
Step 0: 39. Step 1: 3×9=27. Step 2: 2×7=14. Step 3: 1×4=4 (single digit). Total steps: 3.
Solution Hints
55
Points
Points
1000ms
Time Limit
Time Limit
64MB
Memory Limit
Memory Limit
Code Editor
Register to Access Code Editor
Create a free account to solve coding problems and track your progress.
Register Now