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
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
39Expected
32
Input
999Expected
43
Input
4Expected
04
Input
25Expected
25
Input
10Expected
16
Input
0Expected
0Focus radio
Paused · SomaFM · Fluid