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
PostgreSQLv16

Čia bus kodo vykdymo rezultatas

Visible tests
1
Input
38
Expected2
2
Input
0
Expected0
3
Input
9
Expected9
4
Input
199
Expected1
5
Input
12345
Expected6
6
Input
12344
Expected5
Focus radio
Paused · SomaFM · Fluid