Shrink to One Digit
Sometimes a large number is reduced to a single check digit, which is useful in puzzles and simple validation rules. Write digital_root, which adds the digits of n, then adds the digits of the result, and keeps going until only one digit remains. Return that final digit.
Примеры
Ввод
38Вывод
2Ввод
0Вывод
0Ввод
9Вывод
9Нужно реализовать
def digital_root(n: int) -> int:
Теги
math
Log ind for at se indsendelseshistorik
Log indLog ind for at bruge AI-mentor
Log indVisible tests
1
Input
38Expected
22
Input
0Expected
03
Input
9Expected
94
Input
12345Expected
65
Input
99999Expected
96
Input
100Expected
1Focus radio
Paused · SomaFM · Fluid