eolymp
bolt
Try our new interface for solving problems
Problems

Persistent Number

Persistent Number

Given a number $x$, we define a function $p(x)$ as the product of the digits of $x$. We can then form a sequence $x, p(x), p(p(x))...$ . The persistence of $x$ is then defined as the index ($0$-based) of the first single digit number in the sequence. For example, using $99$, we get the sequence $99, 9 \cdot 9 = 81, 8 \cdot 1 = 8$. Thus, the persistence of $99$ is $2$. You will be given $n$, and you must find its persistence. \InputFile Each line contains one integer $n\:(0 \le n \le 2 \cdot 10^9)$. \OutputFile For each number $n$ print on a separate line its persistence.
Time limit 1 second
Memory limit 128 MiB
Input example #1
99
268
6
Output example #1
2
4
0