Add the Digits
Sometimes you need to break a number into its digits, like when calculating a checksum or checking a simple numeric rule. The function sum_digits receives a non-negative integer n and returns the sum of its decimal digits. If n is 0, the digit sum is also 0.
Примеры
Ввод
0Вывод
0Ввод
5Вывод
5Ввод
123Вывод
6Нужно реализовать
def sum_digits(n: int) -> int:
Теги
math
Συνδεθείτε για να δείτε το ιστορικό υποβολών
ΣύνδεσηΣυνδεθείτε για να χρησιμοποιήσετε τον AI Mentor
ΣύνδεσηVisible tests
1
Input
0Expected
02
Input
5Expected
53
Input
123Expected
64
Input
9999Expected
365
Input
1000000Expected
16
Input
8675309Expected
38Focus radio
Paused · SomaFM · Fluid