One-Digit Sum
Sometimes a large number is reduced to a single check digit, as in simple validations and number tricks. Given a non-negative integer num, add all of its digits. If the result still has more than one digit, repeat the process until only one digit remains, then return it.
Примеры
Ввод
38Вывод
2Ввод
0Вывод
0Ввод
9Вывод
9Нужно реализовать
def add_digits(num: int) -> int:
Теги
math
Connectez-vous pour voir l'historique des soumissions
Se connecterConnectez-vous pour utiliser le Mentor IA
Se connecterVisible tests
1
Input
38Expected
22
Input
0Expected
03
Input
9Expected
94
Input
199Expected
15
Input
12345Expected
66
Input
12344Expected
5Focus radio
Paused · SomaFM · Fluid