Functions
Function-42
Function-43
Function-44
~/algor $ cat problems/funksiya-multiplikativ-turgunlik
Digit product steps
Easy
1000 ms
128 MB
31%
Write a function Persistence(x) that returns how many steps it takes for the positive integer $x$ to become a single digit if at each step it is replaced by the product of its digits.
Example 1: Persistence(39) → 3 — $39 \to 27 \to 14 \to 4$, $3$ steps.
Example 2: Persistence(7) → 0 — the number already has one digit, no steps are needed.
Write only the function body.
Input
One line with a positive integer $x$ — the argument of the function.
Output
The value returned by the function: an integer.
Note
$1 \le x \le 10^{15}$
Examples
Input #1
39
Output #1
3
Input #2
7
Output #2
0