This question already has an answer here:
- Additive Persistence 38 answers
Write a program or function that, when given a number, outputs its persistence. The persistence of a number is the number of times you can add its digits before arriving at a one-digit number. All one digit numbers have a persistence of 0. Note that this is different from questions about finding the digital root, as those questions ask for the end result of this process, whereas this question wants the number of steps required to get there.
The persistence of the inputted integer.
1-->0 (1=1) 12-->1 (1+2=3) 99-->2 (9+9=18, 1+8=9) 9999-->2 (9+9+9+9=36, 3+6=9)
This is code-golf, lowest score in bytes wins.