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
PostgreSQLv16
Entre para enviar

O resultado da execução do código aparecerá aqui

Visible tests
1
Input
0
Expected0
2
Input
5
Expected5
3
Input
123
Expected6
4
Input
9999
Expected36
5
Input
1000000
Expected1
6
Input
8675309
Expected38
Focus radio
Paused · SomaFM · Fluid