Digit Product Countdown

Sometimes you can shrink a number by multiplying all of its digits together, then repeating the same process with the result. Write persistence so it returns how many steps it takes to reduce n to a single digit. If n is already one digit, no steps are needed, so return 0.

Примеры

Ввод
39
Вывод
3
Ввод
999
Вывод
4
Ввод
4
Вывод
0

Нужно реализовать

def persistence(n: int) -> int:

Теги

math
PostgreSQLv16

Тук ще се появи резултатът от изпълнението на кода

Visible tests
1
Input
39
Expected3
2
Input
999
Expected4
3
Input
4
Expected0
4
Input
25
Expected2
5
Input
10
Expected1
6
Input
0
Expected0
Focus radio
Paused · SomaFM · Fluid